Re: [libvirt] PATCH: Support initial boot time CPU affinity mask

2008-05-22 Thread Daniel P. Berrange
On Wed, May 21, 2008 at 11:33:33AM -0400, Daniel Veillard wrote:
 On Fri, May 16, 2008 at 10:50:20PM +0100, Daniel P. Berrange wrote:
  +/* Extract domain vcpu info */
  +obj = xmlXPathEval(BAD_CAST string(/domain/vcpu[1]/@cpuset), ctxt);
  +if ((obj == NULL) || (obj-type != XPATH_STRING) ||
  +(obj-stringval == NULL) || (obj-stringval[0] == 0)) {
  +/* Allow use on all CPUS */
  +memset(def-cpumask, 1, QEMUD_CPUMASK_LEN);
  +} else {
  +char *set = (char *)obj-stringval;
  +memset(def-cpumask, 0, QEMUD_CPUMASK_LEN);
  +if (virParseCpuSet(conn, (const char **)set,
  +   0, def-cpumask,
  +   QEMUD_CPUMASK_LEN)  0) {
  +qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
  + %s, _(malformed vcpu mask information));
  +goto error;
  +}
  +}
  +xmlXPathFreeObject(obj);
 
   virXPathString() would make it way cleaner IMHO

It definitely would - this entire funciton uses the old style direct
API calls and needs switching over.

   Patch looks fine. Since we have migration nearly ready, it would be 
 interesting to check the combination of both at some point too,
 
   Looks fine to me, +1,

Thanks, I've committed this patch, including the bug Jim pointed out about
the unneccessary -S arg when using migrateFrom args

Regards,
Daniel
-- 
|: Red Hat, Engineering, Boston   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org   -o- http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] PATCH: Support initial boot time CPU affinity mask

2008-05-21 Thread Daniel Veillard
On Fri, May 16, 2008 at 10:50:20PM +0100, Daniel P. Berrange wrote:
 The XML format allows for an initial CPU mask to be specified for a guests
 vCPUs. eg with this XML:
 
   vcpu cpuset='1-4,8-20,525'1/vcpu

  what about output. In the xen case we went though the exercise to
dump a cpuset string back only if it wasn't 'all set'.

 Since we have CPU pinning support from my previous patch, adding in the
 initial pinning is fairly easy. We first pass the '-S' arg to QEMU when
 forking it. This causes it to initialize, but not start the CPUs in the
 guest. We then set the affinity mask for all its CPUs, and then send 
 the 'cont' command to the monitor to start execution.
[...]
 +/* Extract domain vcpu info */
 +obj = xmlXPathEval(BAD_CAST string(/domain/vcpu[1]/@cpuset), ctxt);
 +if ((obj == NULL) || (obj-type != XPATH_STRING) ||
 +(obj-stringval == NULL) || (obj-stringval[0] == 0)) {
 +/* Allow use on all CPUS */
 +memset(def-cpumask, 1, QEMUD_CPUMASK_LEN);
 +} else {
 +char *set = (char *)obj-stringval;
 +memset(def-cpumask, 0, QEMUD_CPUMASK_LEN);
 +if (virParseCpuSet(conn, (const char **)set,
 +   0, def-cpumask,
 +   QEMUD_CPUMASK_LEN)  0) {
 +qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
 + %s, _(malformed vcpu mask information));
 +goto error;
 +}
 +}
 +xmlXPathFreeObject(obj);

  virXPathString() would make it way cleaner IMHO

[...]
  virBufferVSprintf(buf,   memory%lu/memory\n, def-maxmem);
  virBufferVSprintf(buf,   currentMemory%lu/currentMemory\n, 
 def-memory);
 -virBufferVSprintf(buf,   vcpu%d/vcpu\n, def-vcpus);
 +
 +for (n = 0 ; n  QEMUD_CPUMASK_LEN ; n++)
 +if (def-cpumask[n] != 1)
 +allones = 0;
 +
 +if (allones) {
 +virBufferVSprintf(buf,   vcpu%d/vcpu\n, def-vcpus);

  okay that answers my question :-)


  Patch looks fine. Since we have migration nearly ready, it would be 
interesting to check the combination of both at some point too,

  Looks fine to me, +1,

Daniel

-- 
Red Hat Virtualization group http://redhat.com/virtualization/
Daniel Veillard  | virtualization library  http://libvirt.org/
[EMAIL PROTECTED]  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine  http://rpmfind.net/

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


[libvirt] PATCH: Support initial boot time CPU affinity mask

2008-05-16 Thread Daniel P. Berrange
The XML format allows for an initial CPU mask to be specified for a guests
vCPUs. eg with this XML:

  vcpu cpuset='1-4,8-20,525'1/vcpu

Since we have CPU pinning support from my previous patch, adding in the
initial pinning is fairly easy. We first pass the '-S' arg to QEMU when
forking it. This causes it to initialize, but not start the CPUs in the
guest. We then set the affinity mask for all its CPUs, and then send 
the 'cont' command to the monitor to start execution.


 src/qemu_conf.c|   44 +++
 src/qemu_conf.h|3 
 src/qemu_driver.c  |   77 +
 src/xml.c  |5 
 src/xml.h  |4 
 tests/qemuxml2argvdata/qemuxml2argv-boot-cdrom.args|2 
 tests/qemuxml2argvdata/qemuxml2argv-boot-floppy.args   |2 
 tests/qemuxml2argvdata/qemuxml2argv-boot-network.args  |2 
 tests/qemuxml2argvdata/qemuxml2argv-bootloader.args|2 
 tests/qemuxml2argvdata/qemuxml2argv-clock-localtime.args   |2 
 tests/qemuxml2argvdata/qemuxml2argv-clock-utc.args |2 
 tests/qemuxml2argvdata/qemuxml2argv-console-compat.args|2 
 tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom.args|2 
 tests/qemuxml2argvdata/qemuxml2argv-disk-floppy.args   |2 
 tests/qemuxml2argvdata/qemuxml2argv-disk-many.args |2 
 tests/qemuxml2argvdata/qemuxml2argv-disk-virtio.args   |2 
 tests/qemuxml2argvdata/qemuxml2argv-disk-xenvbd.args   |2 
 tests/qemuxml2argvdata/qemuxml2argv-graphics-sdl.args  |2 
 tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc.args  |2 
 tests/qemuxml2argvdata/qemuxml2argv-input-usbmouse.args|2 
 tests/qemuxml2argvdata/qemuxml2argv-input-usbtablet.args   |2 
 tests/qemuxml2argvdata/qemuxml2argv-input-xen.args |2 
 tests/qemuxml2argvdata/qemuxml2argv-minimal.args   |2 
 tests/qemuxml2argvdata/qemuxml2argv-minimal.xml|2 
 tests/qemuxml2argvdata/qemuxml2argv-misc-acpi.args |2 
 tests/qemuxml2argvdata/qemuxml2argv-misc-no-reboot.args|2 
 tests/qemuxml2argvdata/qemuxml2argv-net-user.args  |2 
 tests/qemuxml2argvdata/qemuxml2argv-net-virtio.args|2 
 tests/qemuxml2argvdata/qemuxml2argv-parallel-tcp.args  |2 
 tests/qemuxml2argvdata/qemuxml2argv-serial-dev.args|2 
 tests/qemuxml2argvdata/qemuxml2argv-serial-file.args   |2 
 tests/qemuxml2argvdata/qemuxml2argv-serial-many.args   |2 
 tests/qemuxml2argvdata/qemuxml2argv-serial-pty.args|2 
 tests/qemuxml2argvdata/qemuxml2argv-serial-tcp-telnet.args |2 
 tests/qemuxml2argvdata/qemuxml2argv-serial-tcp.args|2 
 tests/qemuxml2argvdata/qemuxml2argv-serial-udp.args|2 
 tests/qemuxml2argvdata/qemuxml2argv-serial-unix.args   |2 
 tests/qemuxml2argvdata/qemuxml2argv-serial-vc.args |2 
 tests/qemuxml2argvdata/qemuxml2argv-sound.args |2 
 39 files changed, 140 insertions(+), 61 deletions(-)

Dan.

diff -r 3bbea433803f src/qemu_conf.c
--- a/src/qemu_conf.c   Fri May 16 17:39:29 2008 -0400
+++ b/src/qemu_conf.c   Fri May 16 17:40:39 2008 -0400
@@ -56,6 +56,7 @@
 #include memory.h
 #include verify.h
 #include c-ctype.h
+#include xml.h
 
 #define qemudLog(level, msg...) fprintf(stderr, msg)
 
@@ -1743,6 +1744,25 @@
 }
 xmlXPathFreeObject(obj);
 
+/* Extract domain vcpu info */
+obj = xmlXPathEval(BAD_CAST string(/domain/vcpu[1]/@cpuset), ctxt);
+if ((obj == NULL) || (obj-type != XPATH_STRING) ||
+(obj-stringval == NULL) || (obj-stringval[0] == 0)) {
+/* Allow use on all CPUS */
+memset(def-cpumask, 1, QEMUD_CPUMASK_LEN);
+} else {
+char *set = (char *)obj-stringval;
+memset(def-cpumask, 0, QEMUD_CPUMASK_LEN);
+if (virParseCpuSet(conn, (const char **)set,
+   0, def-cpumask,
+   QEMUD_CPUMASK_LEN)  0) {
+qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ %s, _(malformed vcpu mask information));
+goto error;
+}
+}
+xmlXPathFreeObject(obj);
+
 /* See if ACPI feature is requested */
 obj = xmlXPathEval(BAD_CAST /domain/features/acpi, ctxt);
 if ((obj != NULL)  (obj-type == XPATH_NODESET) 
@@ -2431,6 +2451,7 @@
 disableKQEMU = 1;
 
 len = 1 + /* qemu */
+1 + /* Stopped */
 2 + /* machine type */
 disableKQEMU + /* Disable kqemu */
 (vm-qemuCmdFlags  QEMUD_CMD_FLAG_NAME ? 2 : 0) + /* -name XXX */
@@ -2464,6 +2485,8 @@
 goto no_memory;
 if (!((*argv)[++n] = strdup(vm-def-os.binary)))
 goto no_memory;
+if (!((*argv)[++n] = strdup(-S)))
+goto no_memory;
 if (!((*argv)[++n] = 

Re: [libvirt] PATCH: Support initial boot time CPU affinity mask

2008-05-16 Thread Stefan de Konink
On Fri, 16 May 2008, Daniel P. Berrange wrote:

 The XML format allows for an initial CPU mask to be specified for a guests
 vCPUs. eg with this XML:

   vcpu cpuset='1-4,8-20,525'1/vcpu

 Since we have CPU pinning support from my previous patch, adding in the
 initial pinning is fairly easy. We first pass the '-S' arg to QEMU when
 forking it. This causes it to initialize, but not start the CPUs in the
 guest. We then set the affinity mask for all its CPUs, and then send
 the 'cont' command to the monitor to start execution.

Does this include Xen support?


Stefan

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] PATCH: Support initial boot time CPU affinity mask

2008-05-16 Thread Cole Robinson
Stefan de Konink wrote:
 On Fri, 16 May 2008, Daniel P. Berrange wrote:
 
 The XML format allows for an initial CPU mask to be specified for a guests
 vCPUs. eg with this XML:

   vcpu cpuset='1-4,8-20,525'1/vcpu

 Since we have CPU pinning support from my previous patch, adding in the
 initial pinning is fairly easy. We first pass the '-S' arg to QEMU when
 forking it. This causes it to initialize, but not start the CPUs in the
 guest. We then set the affinity mask for all its CPUs, and then send
 the 'cont' command to the monitor to start execution.
 
 Does this include Xen support?
 
 
 Stefan
 

cpu pinning is already support for xen.

- Cole

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] PATCH: Support initial boot time CPU affinity mask

2008-05-16 Thread Jim Paris
Daniel P. Berrange wrote:
 Since we have CPU pinning support from my previous patch, adding in the
 initial pinning is fairly easy. We first pass the '-S' arg to QEMU when
 forking it.

If -S is always added, this becomes unnecessary (qemu_conf.c:2823):

if (vm-migrateFrom[0]) {
if (!((*argv)[++n] = strdup(-S)))
goto no_memory;

-jim

--
Libvir-list mailing list
Libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list