From 4e7b9aa2e1d0ccb58fe9ab140afed22a29eb9be0 Mon Sep 17 00:00:00 2001 From: "Daniel P. Berrange" Date: Thu, 14 Sep 2006 15:34:50 +0000 Subject: [PATCH] Ensure we strip the :disk postfix from disks in Xen 3.0.3 --- ChangeLog | 13 +++++++ src/xend_internal.c | 34 +++++++++++++++---- src/xml.c | 8 ++--- tests/sexpr2xmldata/sexpr2xml-fv-v2.sexpr | 2 +- tests/sexpr2xmltest.c | 4 +-- tests/virshtest.c | 4 +-- tests/xml2sexprdata/xml2sexpr-fv-v2.sexpr | 2 +- .../xml2sexpr-fv-vncunused.sexpr | 2 +- tests/xml2sexprtest.c | 4 +-- 9 files changed, 53 insertions(+), 20 deletions(-) diff --git a/ChangeLog b/ChangeLog index 448015a9f1..bddcd4d1d1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +Thu Sep 14 10:33:23 EDT 2006 Daniel Berrange + + * 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 element, since its already set in + the device attribute on 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 * src/xml.c: Added support for setting VNC port when creating diff --git a/src/xend_internal.c b/src/xend_internal.c index 463da1a192..1df2d0703f 100644 --- a/src/xend_internal.c +++ b/src/xend_internal.c @@ -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: + */ diff --git a/src/xml.c b/src/xml.c index d644a43d91..9d79df6249 100644 --- a/src/xml.c +++ b/src/xml.c @@ -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); diff --git a/tests/sexpr2xmldata/sexpr2xml-fv-v2.sexpr b/tests/sexpr2xmldata/sexpr2xml-fv-v2.sexpr index 398ebca72d..3a69b3aabc 100644 --- a/tests/sexpr2xmldata/sexpr2xml-fv-v2.sexpr +++ b/tests/sexpr2xmldata/sexpr2xml-fv-v2.sexpr @@ -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)))) diff --git a/tests/sexpr2xmltest.c b/tests/sexpr2xmltest.c index 158999bf37..6055293af1 100644 --- a/tests/sexpr2xmltest.c +++ b/tests/sexpr2xmltest.c @@ -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; diff --git a/tests/virshtest.c b/tests/virshtest.c index 90209577bd..f509bce076 100644 --- a/tests/virshtest.c +++ b/tests/virshtest.c @@ -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; diff --git a/tests/xml2sexprdata/xml2sexpr-fv-v2.sexpr b/tests/xml2sexprdata/xml2sexpr-fv-v2.sexpr index 0b7736abd4..5b28406dd5 100644 --- a/tests/xml2sexprdata/xml2sexpr-fv-v2.sexpr +++ b/tests/xml2sexprdata/xml2sexpr-fv-v2.sexpr @@ -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)))) \ No newline at end of file +(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)))) \ No newline at end of file diff --git a/tests/xml2sexprdata/xml2sexpr-fv-vncunused.sexpr b/tests/xml2sexprdata/xml2sexpr-fv-vncunused.sexpr index 9ba7ae83be..bd0d139bf4 100644 --- a/tests/xml2sexprdata/xml2sexpr-fv-vncunused.sexpr +++ b/tests/xml2sexprdata/xml2sexpr-fv-vncunused.sexpr @@ -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)))) \ No newline at end of file +(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)))) \ No newline at end of file diff --git a/tests/xml2sexprtest.c b/tests/xml2sexprtest.c index f5b0b28773..ef15b0060b 100644 --- a/tests/xml2sexprtest.c +++ b/tests/xml2sexprtest.c @@ -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; -- GitLab