Ensure we strip the :disk postfix from disks in Xen 3.0.3

This commit is contained in:
Daniel P. Berrange 2006-09-14 15:34:50 +00:00
parent 1ed4d29208
commit 4e7b9aa2e1
9 changed files with 53 additions and 20 deletions

View File

@ -1,3 +1,16 @@
Thu Sep 14 10:33:23 EDT 2006 Daniel Berrange <berrange@redhat.com>
* src/xml.c: Append :disk for normal disk devices being created
when Xen >= 3.0.3, even though its technically optional
* src/xend_internal.c: Strip the :disk trailing component when
generating XML when Xen >= 3.0.3. We don't want to expose
that postfix in the <target> element, since its already set in
the device attribute on <disk> element.
* tests/sexpr2xmldata/*, tests/xml2sexprdata/*: Update to test
for handling of :disk postfix in sexpr/XML
* tests/virshtest.c, tests/sexpr2xmltest.c, tests/xml2sexprtest.c:
Cast size_t arg to an int to avoid format warnings from printf
Tue Sep 11 20:37:28 EDT 2006 Daniel Berrange <berrange@redhat.com>
* src/xml.c: Added support for setting VNC port when creating

View File

@ -1566,12 +1566,18 @@ xend_parse_sexp_desc(virConnectPtr conn, struct sexpr *root, int xendConfigVersi
}
if (!strncmp(dst, "ioemu:", 6))
dst += 6;
/* New style cdrom config from Xen >= 3.0.3 */
/* New style disk config from Xen >= 3.0.3 */
if (xendConfigVersion > 1) {
char *offset = rindex(dst, ':');
if (offset && !strcmp(offset, ":cdrom")) {
offset[0] = '\0';
cdrom = 1;
if (offset) {
if (!strcmp(offset, ":cdrom")) {
cdrom = 1;
} else if (!strcmp(offset, ":disk")) {
/* defualt anyway */
} else {
/* Unknown, lets pretend its a disk */
}
offset[0] = '\0';
}
}
@ -1599,9 +1605,15 @@ xend_parse_sexp_desc(virConnectPtr conn, struct sexpr *root, int xendConfigVersi
/* New style cdrom config from Xen >= 3.0.3 */
if (xendConfigVersion > 1) {
char *offset = rindex(dst, ':');
if (offset && !strcmp(offset, ":cdrom")) {
offset[0] = '\0';
cdrom = 1;
if (offset) {
if (!strcmp(offset, ":cdrom")) {
cdrom = 1;
} else if (!strcmp(offset, ":disk")) {
/* defualt anyway */
} else {
/* Unknown, lets pretend its a disk */
}
offset[0] = '\0';
}
}
@ -2850,3 +2862,11 @@ xenDaemonCreateLinux(virConnectPtr conn, const char *xmlDesc,
}
#endif /* ! PROXY */
/*
* Local variables:
* indent-tabs-mode: nil
* c-indent-level: 4
* c-basic-offset: 4
* tab-width: 4
* End:
*/

View File

@ -973,15 +973,15 @@ virDomainParseXMLDiskDesc(xmlNodePtr node, virBufferPtr buf, int hvm, int xendCo
* under the hvm (image (os)) block
*/
if (hvm &&
device &&
device &&
!strcmp((const char *)device, "floppy")) {
return 0;
}
/* Xend <= 3.0.2 doesn't include cdrom config here */
if (hvm &&
device &&
!strcmp((const char *)device, "cdrom")) {
device &&
!strcmp((const char *)device, "cdrom")) {
if (xendConfigVersion == 1)
return 0;
else
@ -1002,7 +1002,7 @@ virDomainParseXMLDiskDesc(xmlNodePtr node, virBufferPtr buf, int hvm, int xendCo
if (xendConfigVersion == 1)
virBufferVSprintf(buf, "(dev 'ioemu:%s')", (const char *) tmp);
else /* But newer does not */
virBufferVSprintf(buf, "(dev '%s%s')", (const char *) tmp, cdrom ? ":cdrom" : "");
virBufferVSprintf(buf, "(dev '%s%s')", (const char *) tmp, cdrom ? ":cdrom" : ":disk");
} else
virBufferVSprintf(buf, "(dev '%s')", (const char *) target);

View File

@ -1 +1 @@
(domain (domid 3)(name 'fvtest')(memory 400)(maxmem 400)(vcpus 1)(uuid 'b5d70dd275cdaca517769660b059d8bc')(on_poweroff 'destroy')(on_reboot 'restart')(on_crash 'restart')(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(device_model '/usr/lib64/xen/bin/qemu-dm')(boot c)(acpi 1)(vnc 1)))(device (vbd (dev 'hdc:cdrom')(uname 'file:/root/boot.iso')(mode 'r')))(device (vbd (dev 'hda')(uname 'file:/root/foo.img')(mode 'w')))(device (vif (mac '00:16:3e:1b:b1:47')(bridge 'xenbr0')(script 'vif-bridge')(type ioemu))))
(domain (domid 3)(name 'fvtest')(memory 400)(maxmem 400)(vcpus 1)(uuid 'b5d70dd275cdaca517769660b059d8bc')(on_poweroff 'destroy')(on_reboot 'restart')(on_crash 'restart')(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(device_model '/usr/lib64/xen/bin/qemu-dm')(boot c)(acpi 1)(vnc 1)))(device (vbd (dev 'hdc:cdrom')(uname 'file:/root/boot.iso')(mode 'r')))(device (vbd (dev 'hda:disk')(uname 'file:/root/foo.img')(mode 'w')))(device (vif (mac '00:16:3e:1b:b1:47')(bridge 'xenbr0')(script 'vif-bridge')(type ioemu))))

View File

@ -28,8 +28,8 @@ static int testCompareFiles(const char *xml, const char *sexpr, int xendConfigVe
return -1;
if (getenv("DEBUG_TESTS")) {
printf("In %d '%s'\n", strlen(xmlData), xmlData);
printf("Out %d '%s'\n", strlen(gotxml), gotxml);
printf("Expect %d '%s'\n", (int)strlen(xmlData), xmlData);
printf("Actual %d '%s'\n", (int)strlen(gotxml), gotxml);
}
if (strcmp(xmlData, gotxml))
return -1;

View File

@ -43,8 +43,8 @@ static int testCompareOutput(const char *expect, const char *filter, const char
return -1;
if (getenv("DEBUG_TESTS")) {
printf("Expect %d '%s'\n", strlen(expectData), expectData);
printf("Actual %d '%s'\n", strlen(actualData), actualData);
printf("Expect %d '%s'\n", (int)strlen(expectData), expectData);
printf("Actual %d '%s'\n", (int)strlen(actualData), actualData);
}
if (strcmp(expectData, actualData))
return -1;

View File

@ -1 +1 @@
(vm (name 'fvtest')(memory 400)(maxmem 400)(vcpus 1)(uuid 'b5d70dd275cdaca517769660b059d8bc')(on_poweroff 'destroy')(on_reboot 'restart')(on_crash 'restart')(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(device_model '/usr/lib64/xen/bin/qemu-dm')(boot c)(acpi 1)(vnc 1)(vncdisplay 17)))(device (vbd (dev 'hdc:cdrom')(uname 'file:/root/boot.iso')(mode 'r')))(device (vbd (dev 'hda')(uname 'file:/root/foo.img')(mode 'w')))(device (vif (mac '00:16:3e:1b:b1:47')(bridge 'xenbr0')(script 'vif-bridge')(type ioemu))))
(vm (name 'fvtest')(memory 400)(maxmem 400)(vcpus 1)(uuid 'b5d70dd275cdaca517769660b059d8bc')(on_poweroff 'destroy')(on_reboot 'restart')(on_crash 'restart')(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(device_model '/usr/lib64/xen/bin/qemu-dm')(boot c)(acpi 1)(vnc 1)(vncdisplay 17)))(device (vbd (dev 'hdc:cdrom')(uname 'file:/root/boot.iso')(mode 'r')))(device (vbd (dev 'hda:disk')(uname 'file:/root/foo.img')(mode 'w')))(device (vif (mac '00:16:3e:1b:b1:47')(bridge 'xenbr0')(script 'vif-bridge')(type ioemu))))

View File

@ -1 +1 @@
(vm (name 'fvtest')(memory 400)(maxmem 400)(vcpus 1)(uuid 'b5d70dd275cdaca517769660b059d8bc')(on_poweroff 'destroy')(on_reboot 'restart')(on_crash 'restart')(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(device_model '/usr/lib64/xen/bin/qemu-dm')(boot c)(acpi 1)(vnc 1)(vncunused 1)))(device (vbd (dev 'hdc:cdrom')(uname 'file:/root/boot.iso')(mode 'r')))(device (vbd (dev 'hda')(uname 'file:/root/foo.img')(mode 'w')))(device (vif (mac '00:16:3e:1b:b1:47')(bridge 'xenbr0')(script 'vif-bridge')(type ioemu))))
(vm (name 'fvtest')(memory 400)(maxmem 400)(vcpus 1)(uuid 'b5d70dd275cdaca517769660b059d8bc')(on_poweroff 'destroy')(on_reboot 'restart')(on_crash 'restart')(image (hvm (kernel '/usr/lib/xen/boot/hvmloader')(device_model '/usr/lib64/xen/bin/qemu-dm')(boot c)(acpi 1)(vnc 1)(vncunused 1)))(device (vbd (dev 'hdc:cdrom')(uname 'file:/root/boot.iso')(mode 'r')))(device (vbd (dev 'hda:disk')(uname 'file:/root/foo.img')(mode 'w')))(device (vif (mac '00:16:3e:1b:b1:47')(bridge 'xenbr0')(script 'vif-bridge')(type ioemu))))

View File

@ -28,8 +28,8 @@ static int testCompareFiles(const char *xml, const char *sexpr, const char *name
return -1;
if (getenv("DEBUG_TESTS")) {
printf("In %d '%s'\n", strlen(sexprData), sexprData);
printf("Out %d '%s'\n", strlen(gotsexpr), gotsexpr);
printf("Expect %d '%s'\n", (int)strlen(sexprData), sexprData);
printf("Actual %d '%s'\n", (int)strlen(gotsexpr), gotsexpr);
}
if (strcmp(sexprData, gotsexpr))
return -1;