From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Kiszka Subject: Re: [uq/master patch 2/5] kvm: add logging count to slots Date: Sat, 24 Apr 2010 09:34:58 +0200 Message-ID: <4BD29F22.8020806@web.de> References: <20100423170410.914857113@amt.cnet> <20100423170645.675040544@amt.cnet> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enigC35782D1951CA6580F4CF42C" Cc: kvm@vger.kernel.org, qemu-devel@nongnu.org To: Marcelo Tosatti Return-path: Received: from fmmailgate01.web.de ([217.72.192.221]:58667 "EHLO fmmailgate01.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751093Ab0DXHfF (ORCPT ); Sat, 24 Apr 2010 03:35:05 -0400 In-Reply-To: <20100423170645.675040544@amt.cnet> Sender: kvm-owner@vger.kernel.org List-ID: This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigC35782D1951CA6580F4CF42C Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable Marcelo Tosatti wrote: > Otherwise there is no way to differentiate between global and slot=20 > specific logging, so for example=20 >=20 > vga dirty log start > migration start > migration fail >=20 > Disables dirty logging for the vga slot. This is not true (unless there is a bug): Migration logging is tracked via KVMState::migration_log and vga logging via KVMSlot::flags. Both are merged in kvm_set_user_memory_region. Thus no such change is required for upstream. Jan >=20 > Signed-off-by: Marcelo Tosatti >=20 > Index: qemu-kvm/kvm-all.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- qemu-kvm.orig/kvm-all.c > +++ qemu-kvm/kvm-all.c > @@ -47,6 +47,7 @@ typedef struct KVMSlot > ram_addr_t phys_offset; > int slot; > int flags; > + int logging_count; > } KVMSlot; > =20 > typedef struct kvm_dirty_log KVMDirtyLog; > @@ -218,20 +219,11 @@ err: > /* > * dirty pages logging control > */ > -static int kvm_dirty_pages_log_change(target_phys_addr_t phys_addr, > - ram_addr_t size, int flags, int = mask) > +static int kvm_dirty_pages_log_change(KVMSlot *mem, int flags, int mas= k) > { > KVMState *s =3D kvm_state; > - KVMSlot *mem =3D kvm_lookup_matching_slot(s, phys_addr, phys_addr = + size); > int old_flags; > =20 > - if (mem =3D=3D NULL) { > - fprintf(stderr, "BUG: %s: invalid parameters " TARGET_FMT_= plx "-" > - TARGET_FMT_plx "\n", __func__, phys_addr, > - (target_phys_addr_t)(phys_addr + size - 1)); > - return -EINVAL; > - } > - > old_flags =3D mem->flags; > =20 > flags =3D (mem->flags & ~mask) | flags; > @@ -250,16 +242,42 @@ static int kvm_dirty_pages_log_change(ta > =20 > int kvm_log_start(target_phys_addr_t phys_addr, ram_addr_t size) > { > - return kvm_dirty_pages_log_change(phys_addr, size, > - KVM_MEM_LOG_DIRTY_PAGES, > - KVM_MEM_LOG_DIRTY_PAGES); > + KVMState *s =3D kvm_state; > + KVMSlot *mem =3D kvm_lookup_matching_slot(s, phys_addr, phys_addr = + size); > + > + if (mem =3D=3D NULL) { > + fprintf(stderr, "BUG: %s: invalid parameters " TARGET_FMT_= plx "-" > + TARGET_FMT_plx "\n", __func__, phys_addr, > + (target_phys_addr_t)(phys_addr + size - 1)); > + return -EINVAL; > + } > + > + if (mem->logging_count++) > + return 0; > + > + return kvm_dirty_pages_log_change(mem, > + KVM_MEM_LOG_DIRTY_PAGES, > + KVM_MEM_LOG_DIRTY_PAGES); > } > =20 > int kvm_log_stop(target_phys_addr_t phys_addr, ram_addr_t size) > { > - return kvm_dirty_pages_log_change(phys_addr, size, > - 0, > - KVM_MEM_LOG_DIRTY_PAGES); > + KVMState *s =3D kvm_state; > + KVMSlot *mem =3D kvm_lookup_matching_slot(s, phys_addr, phys_addr = + size); > + > + if (mem =3D=3D NULL) { > + fprintf(stderr, "BUG: %s: invalid parameters " TARGET_FMT_= plx "-" > + TARGET_FMT_plx "\n", __func__, phys_addr, > + (target_phys_addr_t)(phys_addr + size - 1)); > + return -EINVAL; > + } > + > + if (--mem->logging_count) > + return 0; > + > + return kvm_dirty_pages_log_change(mem, > + 0, > + KVM_MEM_LOG_DIRTY_PAGES); > } > =20 > static int kvm_set_migration_log(int enable) > @@ -273,12 +291,15 @@ static int kvm_set_migration_log(int ena > for (i =3D 0; i < ARRAY_SIZE(s->slots); i++) { > mem =3D &s->slots[i]; > =20 > - if (!!(mem->flags & KVM_MEM_LOG_DIRTY_PAGES) =3D=3D enable) { > - continue; > - } > - err =3D kvm_set_user_memory_region(s, mem); > - if (err) { > - return err; > + if (mem->memory_size) { > + if (enable) { > + err =3D kvm_log_start(mem->start_addr, mem->memory_siz= e); > + } else { > + err =3D kvm_log_stop(mem->start_addr, mem->memory_size= ); > + } > + if (err) { > + return err; > + } > } > } > return 0; > @@ -442,6 +463,7 @@ static void kvm_set_phys_mem(target_phys > =20 > /* unregister the overlapping slot */ > mem->memory_size =3D 0; > + mem->logging_count =3D 0; > err =3D kvm_set_user_memory_region(s, mem); > if (err) { > fprintf(stderr, "%s: error unregistering overlapping slot:= %s\n", >=20 >=20 > -- > To unsubscribe from this list: send the line "unsubscribe kvm" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html >=20 --------------enigC35782D1951CA6580F4CF42C Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (GNU/Linux) Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org iEYEARECAAYFAkvSnycACgkQitSsb3rl5xTYGACg3sxTbTUxdPY8a0DrlIbM8HeW b6AAnjbZl9yXafPUAbHql50tDdwWEdoL =Va1N -----END PGP SIGNATURE----- --------------enigC35782D1951CA6580F4CF42C-- From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O5a4X-00035R-PW for qemu-devel@nongnu.org; Sat, 24 Apr 2010 03:46:42 -0400 Received: from [140.186.70.92] (port=33120 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O5a4S-0002ht-Jc for qemu-devel@nongnu.org; Sat, 24 Apr 2010 03:46:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O5ZtL-0005Lt-Md for qemu-devel@nongnu.org; Sat, 24 Apr 2010 03:35:09 -0400 Received: from fmmailgate01.web.de ([217.72.192.221]:58669) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O5ZtL-0005LS-8p for qemu-devel@nongnu.org; Sat, 24 Apr 2010 03:35:07 -0400 Message-ID: <4BD29F22.8020806@web.de> Date: Sat, 24 Apr 2010 09:34:58 +0200 From: Jan Kiszka MIME-Version: 1.0 References: <20100423170410.914857113@amt.cnet> <20100423170645.675040544@amt.cnet> In-Reply-To: <20100423170645.675040544@amt.cnet> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enigC35782D1951CA6580F4CF42C" Sender: jan.kiszka@web.de Subject: [Qemu-devel] Re: [uq/master patch 2/5] kvm: add logging count to slots List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Marcelo Tosatti Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigC35782D1951CA6580F4CF42C Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable Marcelo Tosatti wrote: > Otherwise there is no way to differentiate between global and slot=20 > specific logging, so for example=20 >=20 > vga dirty log start > migration start > migration fail >=20 > Disables dirty logging for the vga slot. This is not true (unless there is a bug): Migration logging is tracked via KVMState::migration_log and vga logging via KVMSlot::flags. Both are merged in kvm_set_user_memory_region. Thus no such change is required for upstream. Jan >=20 > Signed-off-by: Marcelo Tosatti >=20 > Index: qemu-kvm/kvm-all.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- qemu-kvm.orig/kvm-all.c > +++ qemu-kvm/kvm-all.c > @@ -47,6 +47,7 @@ typedef struct KVMSlot > ram_addr_t phys_offset; > int slot; > int flags; > + int logging_count; > } KVMSlot; > =20 > typedef struct kvm_dirty_log KVMDirtyLog; > @@ -218,20 +219,11 @@ err: > /* > * dirty pages logging control > */ > -static int kvm_dirty_pages_log_change(target_phys_addr_t phys_addr, > - ram_addr_t size, int flags, int = mask) > +static int kvm_dirty_pages_log_change(KVMSlot *mem, int flags, int mas= k) > { > KVMState *s =3D kvm_state; > - KVMSlot *mem =3D kvm_lookup_matching_slot(s, phys_addr, phys_addr = + size); > int old_flags; > =20 > - if (mem =3D=3D NULL) { > - fprintf(stderr, "BUG: %s: invalid parameters " TARGET_FMT_= plx "-" > - TARGET_FMT_plx "\n", __func__, phys_addr, > - (target_phys_addr_t)(phys_addr + size - 1)); > - return -EINVAL; > - } > - > old_flags =3D mem->flags; > =20 > flags =3D (mem->flags & ~mask) | flags; > @@ -250,16 +242,42 @@ static int kvm_dirty_pages_log_change(ta > =20 > int kvm_log_start(target_phys_addr_t phys_addr, ram_addr_t size) > { > - return kvm_dirty_pages_log_change(phys_addr, size, > - KVM_MEM_LOG_DIRTY_PAGES, > - KVM_MEM_LOG_DIRTY_PAGES); > + KVMState *s =3D kvm_state; > + KVMSlot *mem =3D kvm_lookup_matching_slot(s, phys_addr, phys_addr = + size); > + > + if (mem =3D=3D NULL) { > + fprintf(stderr, "BUG: %s: invalid parameters " TARGET_FMT_= plx "-" > + TARGET_FMT_plx "\n", __func__, phys_addr, > + (target_phys_addr_t)(phys_addr + size - 1)); > + return -EINVAL; > + } > + > + if (mem->logging_count++) > + return 0; > + > + return kvm_dirty_pages_log_change(mem, > + KVM_MEM_LOG_DIRTY_PAGES, > + KVM_MEM_LOG_DIRTY_PAGES); > } > =20 > int kvm_log_stop(target_phys_addr_t phys_addr, ram_addr_t size) > { > - return kvm_dirty_pages_log_change(phys_addr, size, > - 0, > - KVM_MEM_LOG_DIRTY_PAGES); > + KVMState *s =3D kvm_state; > + KVMSlot *mem =3D kvm_lookup_matching_slot(s, phys_addr, phys_addr = + size); > + > + if (mem =3D=3D NULL) { > + fprintf(stderr, "BUG: %s: invalid parameters " TARGET_FMT_= plx "-" > + TARGET_FMT_plx "\n", __func__, phys_addr, > + (target_phys_addr_t)(phys_addr + size - 1)); > + return -EINVAL; > + } > + > + if (--mem->logging_count) > + return 0; > + > + return kvm_dirty_pages_log_change(mem, > + 0, > + KVM_MEM_LOG_DIRTY_PAGES); > } > =20 > static int kvm_set_migration_log(int enable) > @@ -273,12 +291,15 @@ static int kvm_set_migration_log(int ena > for (i =3D 0; i < ARRAY_SIZE(s->slots); i++) { > mem =3D &s->slots[i]; > =20 > - if (!!(mem->flags & KVM_MEM_LOG_DIRTY_PAGES) =3D=3D enable) { > - continue; > - } > - err =3D kvm_set_user_memory_region(s, mem); > - if (err) { > - return err; > + if (mem->memory_size) { > + if (enable) { > + err =3D kvm_log_start(mem->start_addr, mem->memory_siz= e); > + } else { > + err =3D kvm_log_stop(mem->start_addr, mem->memory_size= ); > + } > + if (err) { > + return err; > + } > } > } > return 0; > @@ -442,6 +463,7 @@ static void kvm_set_phys_mem(target_phys > =20 > /* unregister the overlapping slot */ > mem->memory_size =3D 0; > + mem->logging_count =3D 0; > err =3D kvm_set_user_memory_region(s, mem); > if (err) { > fprintf(stderr, "%s: error unregistering overlapping slot:= %s\n", >=20 >=20 > -- > To unsubscribe from this list: send the line "unsubscribe kvm" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html >=20 --------------enigC35782D1951CA6580F4CF42C Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (GNU/Linux) Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org iEYEARECAAYFAkvSnycACgkQitSsb3rl5xTYGACg3sxTbTUxdPY8a0DrlIbM8HeW b6AAnjbZl9yXafPUAbHql50tDdwWEdoL =Va1N -----END PGP SIGNATURE----- --------------enigC35782D1951CA6580F4CF42C--