[libvirt] [PATCH]: Fix sexpr generation again

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



DanB pointed out that my sexpr xend_internal patch from yesterday broke one of
the regression tests.  The problem is that the xenDaemonFormatSxpr{Disk,Net}
functions are shared between domain creation time and attaching disk time.
Unfortunately, though, Xend expects something different during these two times.
 During domain creation time, it wants the "(device" in front of the sexpr,
while during attach time it does not.  To remedy this situation, I added a flag
to these two functions to differentiate between these two modes.  With this
patch in place, all of the regression tests pass.

Signed-off-by: Chris Lalancette <clalance@xxxxxxxxxx>
Index: src/xend_internal.c
===================================================================
RCS file: /data/cvs/libvirt/src/xend_internal.c,v
retrieving revision 1.208
diff -u -r1.208 xend_internal.c
--- a/src/xend_internal.c	5 Aug 2008 16:45:07 -0000	1.208
+++ b/src/xend_internal.c	6 Aug 2008 10:18:21 -0000
@@ -91,13 +91,15 @@
                         virDomainDiskDefPtr def,
                         virBufferPtr buf,
                         int hvm,
-                        int xendConfigVersion);
+                        int xendConfigVersion,
+                        int isAttach);
 static int
 xenDaemonFormatSxprNet(virConnectPtr conn ATTRIBUTE_UNUSED,
                        virDomainNetDefPtr def,
                        virBufferPtr buf,
                        int hvm,
-                       int xendConfigVersion);
+                       int xendConfigVersion,
+                       int isAttach);
 static int
 virDomainXMLDevID(virDomainPtr domain,
                   virDomainDeviceDefPtr dev,
@@ -3898,7 +3900,7 @@
                                     dev->data.disk,
                                     &buf,
                                     STREQ(def->os.type, "hvm") ? 1 : 0,
-                                    priv->xendConfigVersion) < 0)
+                                    priv->xendConfigVersion, 1) < 0)
             goto cleanup;
         break;
 
@@ -3907,7 +3909,7 @@
                                    dev->data.net,
                                    &buf,
                                    STREQ(def->os.type, "hvm") ? 1 : 0,
-                                   priv->xendConfigVersion) < 0)
+                                   priv->xendConfigVersion, 1) < 0)
             goto cleanup;
         break;
 
@@ -5017,7 +5019,8 @@
                         virDomainDiskDefPtr def,
                         virBufferPtr buf,
                         int hvm,
-                        int xendConfigVersion)
+                        int xendConfigVersion,
+                        int isAttach)
 {
     /* Xend (all versions) put the floppy device config
      * under the hvm (image (os)) block
@@ -5032,6 +5035,9 @@
         xendConfigVersion == 1)
         return 0;
 
+    if (!isAttach)
+        virBufferAddLit(buf, "(device ");
+
     /* Normally disks are in a (device (vbd ...)) block
      * but blktap disks ended up in a differently named
      * (device (tap ....)) block.... */
@@ -5085,6 +5091,9 @@
     else
         virBufferAddLit(buf, "(mode 'w')");
 
+    if (!isAttach)
+        virBufferAddLit(buf, ")");
+
     virBufferAddLit(buf, ")");
 
     return 0;
@@ -5109,7 +5118,8 @@
                        virDomainNetDefPtr def,
                        virBufferPtr buf,
                        int hvm,
-                       int xendConfigVersion)
+                       int xendConfigVersion,
+                       int isAttach)
 {
     if (def->type != VIR_DOMAIN_NET_TYPE_BRIDGE &&
         def->type != VIR_DOMAIN_NET_TYPE_NETWORK &&
@@ -5119,6 +5129,9 @@
         return -1;
     }
 
+    if (!isAttach)
+        virBufferAddLit(buf, "(device ");
+
     virBufferAddLit(buf, "(vif ");
 
     virBufferVSprintf(buf,
@@ -5179,6 +5192,9 @@
     if ((hvm) && (xendConfigVersion < 4))
         virBufferAddLit(buf, "(type ioemu)");
 
+    if (!isAttach)
+        virBufferAddLit(buf, ")");
+
     virBufferAddLit(buf, ")");
 
     return 0;
@@ -5439,14 +5455,14 @@
 
     disk = def->disks;
     while (disk) {
-        if (xenDaemonFormatSxprDisk(conn, disk, &buf, hvm, xendConfigVersion) < 0)
+        if (xenDaemonFormatSxprDisk(conn, disk, &buf, hvm, xendConfigVersion, 0) < 0)
             goto error;
         disk = disk->next;
     }
 
     net = def->nets;
     while (net) {
-        if (xenDaemonFormatSxprNet(conn, net, &buf, hvm, xendConfigVersion) < 0)
+        if (xenDaemonFormatSxprNet(conn, net, &buf, hvm, xendConfigVersion, 0) < 0)
             goto error;
         net = net->next;
     }
--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]