]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
Ensure we strip the :disk postfix from disks in Xen 3.0.3
authorDaniel P. Berrange <berrange@redhat.com>
Thu, 14 Sep 2006 15:34:50 +0000 (15:34 +0000)
committerDaniel P. Berrange <berrange@redhat.com>
Thu, 14 Sep 2006 15:34:50 +0000 (15:34 +0000)
ChangeLog
src/xend_internal.c
src/xml.c
tests/sexpr2xmldata/sexpr2xml-fv-v2.sexpr
tests/sexpr2xmltest.c
tests/virshtest.c
tests/xml2sexprdata/xml2sexpr-fv-v2.sexpr
tests/xml2sexprdata/xml2sexpr-fv-vncunused.sexpr
tests/xml2sexprtest.c

index 448015a9f1f5ce2e21d8604880a0020128ca4e48..bddcd4d1d16495b10ddfa7b619feb2f3cfcf7517 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
index 463da1a192e96521cd5aac4249b63ab70bde6d5d..1df2d0703fc1cb6d5bda15847ed59afd1899d3cd 100644 (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:
+ */
index d644a43d91a00eaa437081dcdb5c328baca0e4db..9d79df6249dca1cc909908dc6c4d656672f7d6fb 100644 (file)
--- 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);
 
index 398ebca72d46d95e27d0fbf9fb82fcf97b9e4954..3a69b3aabce468edab577f2278d66850237994e1 100644 (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))))
index 158999bf3722da1489aae48fe5c1e3e4a1753fee..6055293af14d0478a537bd764628f84305898c0c 100644 (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;
index 90209577bd97bbfe53e7e04cd3503a9c2fcd7c3b..f509bce076813b97d04b98c1dbe47c920a2e3d27 100644 (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;
index 0b7736abd40157418bf095236e95f6e288e63da0..5b28406dd54c0418c65b3484dc4b879ad0b8eb29 100644 (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))))
\ 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
index 9ba7ae83be646d213b3c7f3928c4366002236fd2..bd0d139bf4145738ae0c1eb33cb9cb99ba146b3b 100644 (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))))
\ 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
index f5b0b28773d4abb68e6012f1b8cfbe720711c61e..ef15b0060b2d3833cbed2e44526d5a88a19afbe7 100644 (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;