[libvirt] PATCH: Pass -name argument to QEMU

2008-05-12 Thread Daniel P. Berrange
This patch makes libvirt pass the -name argumet to QEMU it if it supported
by the QEMU binary in question. THis allows QEMU to set the VNC title and
allows Xenner to set the Xen guest name in xenstore.

 src/qemu_conf.c  |   19 ++-
 src/qemu_conf.h  |5 +++--
 tests/qemuxml2argvdata/qemuxml2argv-minimal.args |2 +-
 tests/qemuxml2argvtest.c |   23 +++
 4 files changed, 29 insertions(+), 20 deletions(-)


Dan.

diff -r aab96c0c6974 src/qemu_conf.c
--- a/src/qemu_conf.c   Fri May 09 19:24:37 2008 -0400
+++ b/src/qemu_conf.c   Fri May 09 19:30:26 2008 -0400
@@ -492,10 +492,12 @@
 *flags |= QEMUD_CMD_FLAG_KQEMU;
 if (strstr(help, -no-reboot))
 *flags |= QEMUD_CMD_FLAG_NO_REBOOT;
-if (strstr(help, \n-drive))
-*flags |= QEMUD_CMD_FLAG_DRIVE_OPT;
+if (strstr(help, -name))
+*flags |= QEMUD_CMD_FLAG_NAME;
+if (strstr(help, -drive))
+*flags |= QEMUD_CMD_FLAG_DRIVE;
 if (strstr(help, boot=on))
-*flags |= QEMUD_CMD_FLAG_DRIVE_BOOT_OPT;
+*flags |= QEMUD_CMD_FLAG_DRIVE_BOOT;
 if (*version = 9000)
 *flags |= QEMUD_CMD_FLAG_VNC_COLON;
 ret = 0;
@@ -2348,6 +2350,7 @@
 len = 1 + /* qemu */
 2 + /* machine type */
 disableKQEMU + /* Disable kqemu */
+(vm-qemuCmdFlags  QEMUD_CMD_FLAG_NAME ? 2 : 0) + /* -name XXX */
 2 * vm-def-ndisks + /* disks*/
 (vm-def-nnets  0 ? (4 * vm-def-nnets) : 2) + /* networks */
 1 + /* usb */
@@ -2394,6 +2397,12 @@
 if (!((*argv)[++n] = strdup(vcpus)))
 goto no_memory;
 
+if (vm-qemuCmdFlags  QEMUD_CMD_FLAG_NAME) {
+if (!((*argv)[++n] = strdup(-name)))
+goto no_memory;
+if (!((*argv)[++n] = strdup(vm-def-name)))
+goto no_memory;
+}
 /*
  * NB, -nographic *MUST* come before any serial, or monitor
  * or parallel port flags due to QEMU craziness, where it
@@ -2472,11 +2481,11 @@
 }
 
 /* If QEMU supports -drive param instead of old -hda, -hdb, -cdrom .. */
-if (vm-qemuCmdFlags  QEMUD_CMD_FLAG_DRIVE_OPT) {
+if (vm-qemuCmdFlags  QEMUD_CMD_FLAG_DRIVE) {
 int bootCD = 0, bootFloppy = 0, bootDisk = 0;
 
 /* If QEMU supports boot=on for -drive param... */
-if (vm-qemuCmdFlags  QEMUD_CMD_FLAG_DRIVE_BOOT_OPT) {
+if (vm-qemuCmdFlags  QEMUD_CMD_FLAG_DRIVE_BOOT) {
 for (i = 0 ; i  vm-def-os.nBootDevs ; i++) {
 switch (vm-def-os.bootDevs[i]) {
 case QEMUD_BOOT_CDROM:
diff -r aab96c0c6974 src/qemu_conf.h
--- a/src/qemu_conf.h   Fri May 09 19:24:37 2008 -0400
+++ b/src/qemu_conf.h   Fri May 09 19:30:26 2008 -0400
@@ -249,8 +249,9 @@
 QEMUD_CMD_FLAG_KQEMU  = (1  0),
 QEMUD_CMD_FLAG_VNC_COLON  = (1  1),
 QEMUD_CMD_FLAG_NO_REBOOT  = (1  2),
-QEMUD_CMD_FLAG_DRIVE_OPT  = (1  3),
-QEMUD_CMD_FLAG_DRIVE_BOOT_OPT = (1  4),
+QEMUD_CMD_FLAG_DRIVE  = (1  3),
+QEMUD_CMD_FLAG_DRIVE_BOOT = (1  4),
+QEMUD_CMD_FLAG_NAME   = (1  5),
 };
 
 
diff -r aab96c0c6974 tests/qemuxml2argvdata/qemuxml2argv-minimal.args
--- a/tests/qemuxml2argvdata/qemuxml2argv-minimal.args  Fri May 09 19:24:37 
2008 -0400
+++ b/tests/qemuxml2argvdata/qemuxml2argv-minimal.args  Fri May 09 19:30:26 
2008 -0400
@@ -1,1 +1,1 @@
-/usr/bin/qemu -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c 
-hda /dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb
\ No newline at end of file
+/usr/bin/qemu -M pc -m 214 -smp 1 -name QEMUGuest1 -nographic -monitor pty 
-no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -serial none -parallel 
none -usb
\ No newline at end of file
diff -r aab96c0c6974 tests/qemuxml2argvtest.c
--- a/tests/qemuxml2argvtest.c  Fri May 09 19:24:37 2008 -0400
+++ b/tests/qemuxml2argvtest.c  Fri May 09 19:30:26 2008 -0400
@@ -20,7 +20,7 @@
 
 #define MAX_FILE 4096
 
-static int testCompareXMLToArgvFiles(const char *xml, const char *cmd, int 
driveFlag) {
+static int testCompareXMLToArgvFiles(const char *xml, const char *cmd, int 
extraFlags) {
 char xmlData[MAX_FILE];
 char argvData[MAX_FILE];
 char *xmlPtr = (xmlData[0]);
@@ -47,10 +47,7 @@
 vm.qemuVersion = 0 * 1000 * 100 + (8 * 1000) + 1;
 vm.qemuCmdFlags = QEMUD_CMD_FLAG_VNC_COLON |
 QEMUD_CMD_FLAG_NO_REBOOT;
-if (driveFlag) {
-vm.qemuCmdFlags |= QEMUD_CMD_FLAG_DRIVE_OPT;
-vm.qemuCmdFlags |= QEMUD_CMD_FLAG_DRIVE_BOOT_OPT;
-}
+vm.qemuCmdFlags |= extraFlags;
 vm.migrateFrom[0] = '\0';
 
 vmdef-vncActivePort = vmdef-vncPort;
@@ -100,7 +97,7 @@
 
 struct testInfo {
 const char *name;
-int driveFlag;
+int extraFlags;
 };
 
 static int testCompareXMLToArgvHelper(const void *data) {
@@ -111,7 +108,7 @@
  abs_srcdir, info-name);
   

[libvirt] PATCH: Fix KVM maximum vCPU count

2008-05-12 Thread Daniel P. Berrange
Libvirt currently returns '1' when asked for the maximum number of VCPUs
supported for KVM guests. KVM long long ago gained SMP support, so this 
patch fixes it to return 16, whcih is the current supported number. I
don't bother trying to detect old versions of KVM which are UP only 
because I find it hard to believe anyone will be using them.

 qemu_driver.c |4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Dan.


diff -r b644023b5657 src/qemu_driver.c
--- a/src/qemu_driver.c Sat May 10 13:12:04 2008 -0400
+++ b/src/qemu_driver.c Sat May 10 13:12:18 2008 -0400
@@ -1572,10 +1572,8 @@
 if (STRCASEEQ(type, qemu))
 return 16;
 
-/* XXX future KVM will support SMP. Need to probe
-   kernel to figure out KVM module version i guess */
 if (STRCASEEQ(type, kvm))
-return 1;
+return 16;
 
 if (STRCASEEQ(type, kqemu))
 return 1;

-- 
|: 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


[libvirt] PATCH: Allow Xen bus type for input devices in QEMU driver

2008-05-12 Thread Daniel P. Berrange
The Xenner virtual machine supportes a bus type of 'xen' for input devices,
corresponding to the paravirtualized mouse device. QEMU currently rejects
any bus type which isn't ps2 or usb. This patch makes it allow 'xen' as a
valid bus type for Xenner guests.

 b/tests/qemuxml2argvdata/qemuxml2argv-input-xen.args |1 
 b/tests/qemuxml2argvdata/qemuxml2argv-input-xen.xml  |   24 ++
 src/qemu_conf.c  |   72 ---
 src/qemu_conf.h  |3 
 src/qemu_driver.c|2 
 tests/qemuxml2argvtest.c |2 
 tests/qemuxml2xmltest.c  |1 
 7 files changed, 78 insertions(+), 27 deletions(-)


Dan.

diff -r f00771a60241 src/qemu_conf.c
--- a/src/qemu_conf.c   Sat May 10 12:57:47 2008 -0400
+++ b/src/qemu_conf.c   Sat May 10 13:00:01 2008 -0400
@@ -1365,6 +1365,7 @@
 
 /* Parse the XML definition for a network interface */
 static int qemudParseInputXML(virConnectPtr conn,
+  struct qemud_vm_def *vm,
   struct qemud_vm_input_def *input,
   xmlNodePtr node) {
 xmlChar *type = NULL;
@@ -1391,26 +1392,46 @@
 }
 
 if (bus) {
-if (STREQ((const char*)bus, ps2)) { /* Only allow mouse */
-if (input-type == QEMU_INPUT_TYPE_TABLET) {
-qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
- _(ps2 bus does not support %s input device),
- (const char*)type);
-goto error;
-}
-input-bus = QEMU_INPUT_BUS_PS2;
-} else if (STREQ((const char *)bus, usb)) { /* Allow mouse  
keyboard */
-input-bus = QEMU_INPUT_BUS_USB;
-} else {
-qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
- _(unsupported input bus %s), (const char*)bus);
-goto error;
-}
-} else {
-if (input-type == QEMU_INPUT_TYPE_MOUSE)
-input-bus = QEMU_INPUT_BUS_PS2;
-else
-input-bus = QEMU_INPUT_BUS_USB;
+if (STREQ(vm-os.type, hvm)) {
+if (STREQ((const char*)bus, ps2)) { /* Only allow mouse */
+if (input-type == QEMU_INPUT_TYPE_TABLET) {
+qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ _(ps2 bus does not support %s input 
device),
+ (const char*)type);
+goto error;
+}
+input-bus = QEMU_INPUT_BUS_PS2;
+} else if (STREQ((const char *)bus, usb)) { /* Allow mouse  
tablet */
+input-bus = QEMU_INPUT_BUS_USB;
+} else {
+qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ _(unsupported input bus %s), (const 
char*)bus);
+goto error;
+}
+} else {
+if (STREQ((const char *)bus, xen)) { /* Allow mouse only */
+input-bus = QEMU_INPUT_BUS_XEN;
+if (input-type == QEMU_INPUT_TYPE_TABLET) {
+qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ _(xen bus does not support %s input 
device),
+ (const char*)type);
+goto error;
+}
+} else {
+qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ _(unsupported input bus %s), (const 
char*)bus);
+goto error;
+}
+}
+} else {
+if (!strcmp(vm-os.type, hvm)) {
+if (input-type == QEMU_INPUT_TYPE_MOUSE)
+input-bus = QEMU_INPUT_BUS_PS2;
+else
+input-bus = QEMU_INPUT_BUS_USB;
+} else {
+input-bus = QEMU_INPUT_BUS_XEN;
+}
 }
 
 xmlFree(type);
@@ -1998,7 +2019,7 @@
  %s, _(failed to allocate space for input string));
 goto error;
 }
-if (qemudParseInputXML(conn, input, obj-nodesetval-nodeTab[i])  
0) {
+if (qemudParseInputXML(conn, def, input, 
obj-nodesetval-nodeTab[i])  0) {
 free(input);
 goto error;
 }
@@ -2852,7 +2873,7 @@
 
 struct qemud_vm_device_def *
 qemudParseVMDeviceDef(virConnectPtr conn,
-  struct qemud_driver *driver ATTRIBUTE_UNUSED,
+  struct qemud_vm_def *def,
   const char *xmlStr)
 {
 xmlDocPtr xml;
@@ -2880,7 +2901,7 @@
 qemudParseInterfaceXML(conn, (dev-data.net), node);
 } else if (xmlStrEqual(node-name, BAD_CAST input)) {
 dev-type = QEMUD_DEVICE_DISK;
-

[libvirt] PATCH: Allow xen bus type for disks in QEMU driver

2008-05-12 Thread Daniel P. Berrange
With the recent work to support -drive arg, the QEMU driver now supports
many types of bus for disks attached to VMs - ide, scsi, virtio. This patches
adds another type 'xen' for the Xen blkfront driver. 

 b/tests/qemuxml2argvdata/qemuxml2argv-disk-xenvbd.args |1 
 b/tests/qemuxml2argvdata/qemuxml2argv-disk-xenvbd.xml  |   35 +
 src/qemu_conf.c|8 ++-
 src/qemu_conf.h|1 
 src/util.c |   24 ---
 tests/qemuxml2xmltest.c|1 
 6 files changed, 53 insertions(+), 17 deletions(-)

Dan.

diff -r f6b47c9986b9 src/qemu_conf.c
--- a/src/qemu_conf.c   Sat May 10 12:57:20 2008 -0400
+++ b/src/qemu_conf.c   Sat May 10 12:57:46 2008 -0400
@@ -667,7 +667,8 @@
 if ((!device || STREQ((const char *)device, disk)) 
 !STRPREFIX((const char *)target, hd) 
 !STRPREFIX((const char *)target, sd) 
-!STRPREFIX((const char *)target, vd)) {
+!STRPREFIX((const char *)target, vd) 
+!STRPREFIX((const char *)target, xvd)) {
 qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
  _(Invalid harddisk device name: %s), target);
 goto error;
@@ -707,6 +708,8 @@
 disk-bus = QEMUD_DISK_BUS_SCSI;
 else if (STREQ((const char *)bus, virtio))
 disk-bus = QEMUD_DISK_BUS_VIRTIO;
+else if (STREQ((const char *)bus, xen))
+disk-bus = QEMUD_DISK_BUS_XEN;
 else {
 qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
  _(Invalid bus type: %s), bus);
@@ -1435,7 +1438,8 @@
 const char *busnames[] = { ide,
(qemuIF ? floppy : fdc),
scsi,
-   virtio };
+   virtio,
+   xen};
 verify_true(ARRAY_CARDINALITY(busnames) == QEMUD_DISK_BUS_LAST);
 
 return busnames[busId];
diff -r f6b47c9986b9 src/qemu_conf.h
--- a/src/qemu_conf.h   Sat May 10 12:57:20 2008 -0400
+++ b/src/qemu_conf.h   Sat May 10 12:57:46 2008 -0400
@@ -61,6 +61,7 @@
 QEMUD_DISK_BUS_FDC,
 QEMUD_DISK_BUS_SCSI,
 QEMUD_DISK_BUS_VIRTIO,
+QEMUD_DISK_BUS_XEN,
 
 QEMUD_DISK_BUS_LAST
 };
diff -r f6b47c9986b9 src/util.c
--- a/src/util.cSat May 10 12:57:20 2008 -0400
+++ b/src/util.cSat May 10 12:57:46 2008 -0400
@@ -779,23 +779,17 @@
 const char *ptr = NULL;
 int idx = 0;
 
-if (strlen(name)  3)
+if (!STRPREFIX(name, fd) 
+!STRPREFIX(name, hd) 
+!STRPREFIX(name, vd) 
+!STRPREFIX(name, sd) 
+!STRPREFIX(name, xvd))
 return -1;
 
-switch (*name) {
-case 'f':
-case 'h':
-case 'v':
-case 's':
-break;
-default:
-return 0;
-}
-
-if (*(name + 1) != 'd')
-return -1;
-
-ptr = name+2;
+if (STRPREFIX(name, xvd))
+ptr = name+3;
+else
+ptr = name+2;
 
 while (*ptr) {
 idx = idx * 26;
diff -r f6b47c9986b9 tests/qemuxml2argvdata/qemuxml2argv-disk-xenvbd.args
--- /dev/null   Thu Jan 01 00:00:00 1970 +
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-xenvbd.args  Sat May 10 
12:57:47 2008 -0400
@@ -0,0 +1,1 @@
+/usr/bin/qemu -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c 
-drive file=/dev/HostVG/QEMUGuest1,if=ide,index=0,boot=on -drive 
file=/dev/HostVG/QEMUGuest2,if=ide,media=cdrom,index=2 -drive 
file=/tmp/data.img,if=xen,index=0 -drive file=/tmp/logs.img,if=xen,index=6 -net 
none -serial none -parallel none -usb
\ No newline at end of file
diff -r f6b47c9986b9 tests/qemuxml2argvdata/qemuxml2argv-disk-xenvbd.xml
--- /dev/null   Thu Jan 01 00:00:00 1970 +
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-xenvbd.xml   Sat May 10 
12:57:47 2008 -0400
@@ -0,0 +1,35 @@
+domain type='qemu'
+  nameQEMUGuest1/name
+  uuidc7a5fdbd-edaf-9455-926a-d65c16db1809/uuid
+  memory219200/memory
+  currentMemory219200/currentMemory
+  vcpu1/vcpu
+  os
+type arch='i686' machine='pc'hvm/type
+boot dev='hd'/
+  /os
+  clock offset='utc'/
+  on_poweroffdestroy/on_poweroff
+  on_rebootrestart/on_reboot
+  on_crashdestroy/on_crash
+  devices
+emulator/usr/bin/qemu/emulator
+disk type='block' device='disk'
+  source dev='/dev/HostVG/QEMUGuest1'/
+  target dev='hda' bus='ide'/
+/disk
+disk type='block' device='cdrom'
+  source dev='/dev/HostVG/QEMUGuest2'/
+  target dev='hdc' bus='ide'/
+  readonly/
+/disk
+disk type='file' device='disk'
+  source file='/tmp/data.img'/
+  target dev='xvda' bus='xen'/
+/disk
+disk type='file' device='disk'
+  source file='/tmp/logs.img'/
+  target dev='xvdg' bus='xen'/
+/disk
+  /devices
+/domain
diff -r f6b47c9986b9 tests/qemuxml2xmltest.c
--- a/tests/qemuxml2xmltest.c   Sat May 10 12:57:20 2008 

[libvirt] PATCH: Support bootloaders in QEMU driver

2008-05-12 Thread Daniel P. Berrange
The QEMU driver supports booting Xen guests via the Xenner hypervisor.  For
such paravirtualized guests there is no regular BIOS, so the bootloader has
to be run on the host. Xenner defaults  to pygrub, but since libvirt has a
generic syntax for bootloaders, we should use it. So this patch adds support
for the bootloader syntax in the QEMU drive, and passes this to Xenner via
the -bootloader arg.

The patch is overly large, because when we have a bootloader we need to skip
the kernel/initrd/cmdline/boot elements  thus caused alot of intrusive code
re-indentation .

 b/tests/qemuxml2argvdata/qemuxml2argv-bootloader.args |1 
 b/tests/qemuxml2argvdata/qemuxml2argv-bootloader.xml  |   23 +
 src/qemu_conf.c   |  318 +-
 src/qemu_conf.h   |1 
 tests/qemuxml2argvtest.c  |1 
 tests/qemuxml2xmltest.c   |1 
 6 files changed, 200 insertions(+), 145 deletions(-)

Dan.


diff -r f6b693192cb2 src/qemu_conf.c
--- a/src/qemu_conf.c   Mon May 12 09:51:07 2008 -0400
+++ b/src/qemu_conf.c   Mon May 12 10:16:21 2008 -0400
@@ -1702,22 +1702,37 @@
 xmlXPathFreeObject(obj);
 
 
+/* Extract bootloader */
+obj = xmlXPathEval(BAD_CAST string(/domain/bootloader), ctxt);
+if ((obj != NULL)  (obj-type == XPATH_STRING) 
+(obj-stringval != NULL)  (obj-stringval[0] != 0)) {
+strncpy(def-os.bootloader, (const char*)obj-stringval, 
sizeof(def-os.bootloader));
+NUL_TERMINATE(def-os.bootloader);
+xmlXPathFreeObject(obj);
+
+/* Set a default OS type, since type is optional with bootloader */
+strcpy(def-os.type, xen);
+}
+
 /* Extract OS type info */
 obj = xmlXPathEval(BAD_CAST string(/domain/os/type[1]), ctxt);
 if ((obj == NULL) || (obj-type != XPATH_STRING) ||
 (obj-stringval == NULL) || (obj-stringval[0] == 0)) {
+if (!def-os.type[0]) {
+qemudReportError(conn, NULL, NULL, VIR_ERR_OS_TYPE,
+ %s, _(no OS type));
+goto error;
+}
+} else {
+strcpy(def-os.type, (const char *)obj-stringval);
+xmlXPathFreeObject(obj);
+}
+
+if (!virCapabilitiesSupportsGuestOSType(driver-caps, def-os.type)) {
 qemudReportError(conn, NULL, NULL, VIR_ERR_OS_TYPE,
- %s, _(no OS type));
-goto error;
-}
-if (!virCapabilitiesSupportsGuestOSType(driver-caps, (const 
char*)obj-stringval)) {
-qemudReportError(conn, NULL, NULL, VIR_ERR_OS_TYPE,
- %s, obj-stringval);
-goto error;
-}
-strcpy(def-os.type, (const char *)obj-stringval);
-xmlXPathFreeObject(obj);
-
+ %s, def-os.type);
+goto error;
+}
 
 obj = xmlXPathEval(BAD_CAST string(/domain/os/type[1]/@arch), ctxt);
 if ((obj == NULL) || (obj-type != XPATH_STRING) ||
@@ -1772,75 +1787,76 @@
 xmlXPathFreeObject(obj);
 
 
-obj = xmlXPathEval(BAD_CAST string(/domain/os/kernel[1]), ctxt);
-if ((obj != NULL)  (obj-type == XPATH_STRING) 
-(obj-stringval != NULL)  (obj-stringval[0] != 0)) {
-if (strlen((const char *)obj-stringval) = (PATH_MAX-1)) {
-qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
- %s, _(kernel path too long));
-goto error;
-}
-strcpy(def-os.kernel, (const char *)obj-stringval);
-}
-xmlXPathFreeObject(obj);
-
-
-obj = xmlXPathEval(BAD_CAST string(/domain/os/initrd[1]), ctxt);
-if ((obj != NULL)  (obj-type == XPATH_STRING) 
-(obj-stringval != NULL)  (obj-stringval[0] != 0)) {
-if (strlen((const char *)obj-stringval) = (PATH_MAX-1)) {
-qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
- %s, _(initrd path too long));
-goto error;
-}
-strcpy(def-os.initrd, (const char *)obj-stringval);
-}
-xmlXPathFreeObject(obj);
-
-
-obj = xmlXPathEval(BAD_CAST string(/domain/os/cmdline[1]), ctxt);
-if ((obj != NULL)  (obj-type == XPATH_STRING) 
-(obj-stringval != NULL)  (obj-stringval[0] != 0)) {
-if (strlen((const char *)obj-stringval) = (PATH_MAX-1)) {
-qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
- %s, _(cmdline arguments too long));
-goto error;
-}
-strcpy(def-os.cmdline, (const char *)obj-stringval);
-}
-xmlXPathFreeObject(obj);
-
-
-/* analysis of the disk devices */
-obj = xmlXPathEval(BAD_CAST /domain/os/boot, ctxt);
-if ((obj != NULL)  (obj-type == XPATH_NODESET) 
-(obj-nodesetval != NULL)  (obj-nodesetval-nodeNr = 0)) {
-for (i = 0; i  obj-nodesetval-nodeNr  i  QEMUD_MAX_BOOT_DEVS ; 
i++) {
-if (!(prop = xmlGetProp(obj-nodesetval-nodeTab[i], BAD_CAST 
dev)))
-

[libvirt] PATCH: Fix default bus type selection for disks

2008-05-12 Thread Daniel P. Berrange
We recently added a new bus type attribute to disks to select between IDE,
SCSI, etc. This attribute is optional and many tools won't set it. In such
cases we default to IDE, which is clearly wrong. This patch updates it to
pick the default bus based on the prefix of the disk target name, so that
it DWIM, eg  hdXXX == IDE, sdXXX == SCSI, xvdXXX == Xen, etc.

 qemu_conf.c |   16 +---
 1 file changed, 13 insertions(+), 3 deletions(-)


Dan

diff -r 68901592c1ce src/qemu_conf.c
--- a/src/qemu_conf.c   Sat May 10 13:18:35 2008 -0400
+++ b/src/qemu_conf.c   Sat May 10 13:55:59 2008 -0400
@@ -698,10 +698,20 @@
 }
 
 if (!bus) {
-if (disk-device == QEMUD_DISK_FLOPPY)
+if (disk-device == QEMUD_DISK_FLOPPY) {
 disk-bus = QEMUD_DISK_BUS_FDC;
-else
-disk-bus = QEMUD_DISK_BUS_IDE;
+} else {
+if (STRPREFIX((const char *)target, hd))
+disk-bus = QEMUD_DISK_BUS_IDE;
+else if (STRPREFIX((const char *)target, sd))
+disk-bus = QEMUD_DISK_BUS_SCSI;
+else if (STRPREFIX((const char *)target, vd))
+disk-bus = QEMUD_DISK_BUS_VIRTIO;
+else if (STRPREFIX((const char *)target, xvd))
+disk-bus = QEMUD_DISK_BUS_XEN;
+else
+disk-bus = QEMUD_DISK_BUS_IDE;
+}
 } else if (STREQ((const char *)bus, ide))
 disk-bus = QEMUD_DISK_BUS_IDE;
 else if (STREQ((const char *)bus, fdc))


-- 
|: 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: Fix KVM maximum vCPU count

2008-05-12 Thread Atsushi SAKAI
Hi, Dan

I think the qemu_driver should check KVM_API_VERSION for SMP support.
How do you think?
I am worrying about MAX_VCPUS=16 changes to 32 in future.

Thanks
Atsushi SAKAI

Daniel P. Berrange [EMAIL PROTECTED] wrote:

 I don't bother trying to detect old versions of KVM which are UP only 
 because I find it hard to believe anyone will be using them.


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


Re: [libvirt] [PATCH] Bind to ip_addr support.

2008-05-12 Thread Stefan de Konink
On Tue, 13 May 2008, Daniel P. Berrange wrote:

 On Sat, May 10, 2008 at 07:42:51PM +0200, Stefan de Konink wrote:
  About mdns, do you think it would be a good thing to *not* follow the
  Avahi advise and explicitly set the host the service is running on? In my
  humble opinion I think that would be a wise decision.
 
  hostThe host this services is residing on. We recommend to pass NULL
  here, the daemon will than automatically insert the local host name in
  that case
 
  I wonder how avahi will decide if the service doesn't run on 0.0.0.0 but
  on a specific address. Then we still have domain left, but with a bit
  smart implementation upstream that could just work.

 Well the  'host' parameter of the avahi_entry_group_add_service() method
 does not control which interfaces Avahi broadcasts on. It merely controls
 the hostname included in the advertisement. So if a machine had 2 nics and
 libvirt was only listening on one NIC, by setting this explicitly it means
 we'd be broadcasting on both NICs still, but the advertisment will have an
 IP address that's not reachable via one of the NICs.

I have have send a patch to avahi to prevent this. In avahi you are now
able to set the actual interface that is allowed to be broadcasted on.
allow-interfaces and deny-interfaces.


  The attached patch explicitly sets the host of the mDNS advertisement.
 
 
  Because of some 'unexpected' behavior... I hoped strdup(NULL) would just
  work, but it didn't, I placed it inside an if loop. The debug message
  doesn't mind '(null)' but I think 0.0.0.0 is more appropriate.

 NB, libvirt is explicitly written to be protocol independant - so avoid
 refering to '0.0.0.0' which is IPv4 specific. We fully support IPv6 and
 it is enabled by default if the host OS has IPv6 enabled (which all
 Fedora since FC6 do)

  @@ -440,18 +441,28 @@
   }
   }
 
  -struct libvirtd_mdns_entry *libvirtd_mdns_add_entry(struct 
  libvirtd_mdns_group *group, const char *type, int port) {
  +struct libvirtd_mdns_entry *libvirtd_mdns_add_entry(struct 
  libvirtd_mdns_group *group, const char *type, const char *host, int port) {
   struct libvirtd_mdns_entry *entry = malloc(sizeof(*entry));
 
  -AVAHI_DEBUG(Adding entry %s %d to group %s, type, port, group-name);
  +AVAHI_DEBUG(Adding entry %s %s %d to group %s, type, (host == NULL ? 
  0.0.0.0 : host), port, group-name);

 This is misleading - NULL indicates bind to all addresses which includes
 IPv6 if enabled - 0.0.0.0 is IPv4 only. Since this is only a debug message
 its not too troubling. Just pass in 'host' unchanged - sprintf will output
 it as '(null)' which is more accurate.

Oki.

  +
  +if (host != NULL) {
  +if (!(entry-host = strdup(host))) {
  +   free(entry-type);
  +free(entry);

 There is indentation whitespace damage here. Please check the HACKING
 file for details of how to setup vim and emacs to comply with libvirt
 indentation rules automatically.

Update and resubmit?



Stefan

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


Re: [libvirt] [PATCH] Bind to ip_addr support.

2008-05-12 Thread Stefan de Konink

Daniel P. Berrange schreef:

There is indentation whitespace damage here. Please check the HACKING
file for details of how to setup *vim* and emacs to comply with libvirt
indentation rules automatically.


What is the vim suggestion made there? I see emacs en GNU indent.


Stefan

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