From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44741) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aYLaL-0002tr-7x for qemu-devel@nongnu.org; Tue, 23 Feb 2016 17:37:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aYLaH-0005y5-6Y for qemu-devel@nongnu.org; Tue, 23 Feb 2016 17:37:37 -0500 Received: from mail-pf0-x234.google.com ([2607:f8b0:400e:c00::234]:35072) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aYLaG-0005xq-Mt for qemu-devel@nongnu.org; Tue, 23 Feb 2016 17:37:33 -0500 Received: by mail-pf0-x234.google.com with SMTP id c10so324120pfc.2 for ; Tue, 23 Feb 2016 14:37:32 -0800 (PST) Sender: fluxion Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Michael Roth In-Reply-To: <1446475788-11190-1-git-send-email-ghammer@redhat.com> References: <1446475788-11190-1-git-send-email-ghammer@redhat.com> Message-ID: <20160223223719.29588.7465@loki> Date: Tue, 23 Feb 2016 16:37:19 -0600 Subject: Re: [Qemu-devel] [PATCH] qga: implement the guest-set-vcpus for windows List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gal Hammer , qemu-devel@nongnu.org Quoting Gal Hammer (2015-11-02 08:49:48) > Signed-off-by: Gal Hammer > --- > qga/commands-win32.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++= ++++-- > 1 file changed, 64 insertions(+), 2 deletions(-) > = > diff --git a/qga/commands-win32.c b/qga/commands-win32.c > index d9de23b..a8eb4a0 100644 > --- a/qga/commands-win32.c > +++ b/qga/commands-win32.c > @@ -1181,7 +1181,69 @@ void qmp_guest_set_time(bool has_time, int64_t tim= e_ns, Error **errp) > = > GuestLogicalProcessorList *qmp_guest_get_vcpus(Error **errp) > { > - error_setg(errp, QERR_UNSUPPORTED); > + PSYSTEM_LOGICAL_PROCESSOR_INFORMATION pslpi, ptr; > + DWORD length; > + GuestLogicalProcessorList *head, **link; > + Error *local_err =3D NULL; > + int64_t current; > + > + ptr =3D pslpi =3D NULL; > + length =3D 0; > + current =3D 0; > + head =3D NULL; > + link =3D &head; > + > + if ((GetLogicalProcessorInformation(pslpi, &length) =3D=3D FALSE) && > + (GetLastError() =3D=3D ERROR_INSUFFICIENT_BUFFER) && > + (length > sizeof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION))) { > + ptr =3D pslpi =3D g_malloc0(length); > + if (GetLogicalProcessorInformation(pslpi, &length) =3D=3D FALSE)= { > + error_setg(&local_err, "Failed to get processor information:= %d", > + (int)GetLastError()); > + } > + } else { > + error_setg(&local_err, > + "Failed to get processor information buffer length: %= d", > + (int)GetLastError()); > + } > + > + while ((local_err =3D=3D NULL) && (length > 0)) { > + if (pslpi->Relationship =3D=3D RelationProcessorCore) { > + ULONG_PTR cpu_bits =3D pslpi->ProcessorMask; > + > + while (cpu_bits > 0) { > + if (!!(cpu_bits & 1)) { > + GuestLogicalProcessor *vcpu; > + GuestLogicalProcessorList *entry; > + > + vcpu =3D g_malloc0(sizeof *vcpu); > + vcpu->logical_id =3D current++; > + vcpu->online =3D true; > + vcpu->has_can_offline =3D false; > + > + entry =3D g_malloc0(sizeof *entry); > + entry->value =3D vcpu; > + > + *link =3D entry; > + link =3D &entry->next; > + } > + cpu_bits >>=3D 1; > + } > + } > + length -=3D sizeof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION); > + pslpi++; /* next entry */ > + } > + > + g_free(ptr); > + > + if (local_err =3D=3D NULL) { > + /* there's no guest with zero VCPUs */ > + g_assert(head !=3D NULL); I think we should report that via error_setg() rather than assert. Since it's a minor I can fix that up on my end though: Reviewed-by: Michael Roth Sorry for the delay in getting to this. Need to test, but plan on pulling this in for 2.6. > + return head; > + } > + > + qapi_free_GuestLogicalProcessorList(head); > + error_propagate(errp, local_err); > return NULL; > } > = > @@ -1295,7 +1357,7 @@ GList *ga_command_blacklist_init(GList *blacklist) > { > const char *list_unsupported[] =3D { > "guest-suspend-hybrid", > - "guest-get-vcpus", "guest-set-vcpus", > + "guest-set-vcpus", > "guest-get-memory-blocks", "guest-set-memory-blocks", > "guest-get-memory-block-size", > "guest-fsfreeze-freeze-list", > -- = > 2.1.0 >=20