[libvirt] [PATCH] Fix floppy definition for HVM guests

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

 



# HG changeset patch
# User john.levon@xxxxxxx
# Date 1233177786 28800
# Node ID 2b9283e83c20ca2a18f2cafcb963ce254e11dbb4
# Parent  9a9bd34ec485ebaf4c3861bdfffd2953fd91a1fc
Fix floppy definition for HVM guests

Code was missing to define floppy disks for Xen HVM guests.  Refuse to
attach disks that aren't supported by direct attach.

Signed-off-by: John Levon <john.levon@xxxxxxx>

diff --git a/src/xend_internal.c b/src/xend_internal.c
--- a/src/xend_internal.c
+++ b/src/xend_internal.c
@@ -5018,14 +5018,26 @@ xenDaemonFormatSxprDisk(virConnectPtr co
      * under the hvm (image (os)) block
      */
     if (hvm &&
-        def->device == VIR_DOMAIN_DISK_DEVICE_FLOPPY)
+        def->device == VIR_DOMAIN_DISK_DEVICE_FLOPPY) {
+        if (isAttach) {
+            virXendError(conn, VIR_ERR_INVALID_ARG,
+                     _("Cannot directly attach floppy %s"), def->src);
+            return -1;
+        }
         return 0;
+    }
 
     /* Xend <= 3.0.2 doesn't include cdrom config here */
     if (hvm &&
         def->device == VIR_DOMAIN_DISK_DEVICE_CDROM &&
-        xendConfigVersion == 1)
+        xendConfigVersion == 1) {
+        if (isAttach) {
+            virXendError(conn, VIR_ERR_INVALID_ARG,
+                     _("Cannot directly attach CDROM %s"), def->src);
+            return -1;
+        }
         return 0;
+    }
 
     if (!isAttach)
         virBufferAddLit(buf, "(device ");
@@ -5374,17 +5386,29 @@ xenDaemonFormatSxpr(virConnectPtr conn,
             }
             virBufferVSprintf(&buf, "(boot %s)", bootorder);
 
-            /* get the cdrom device file */
-            /* Only XenD <= 3.0.2 wants cdrom config here */
-            if (xendConfigVersion == 1) {
-                for (i = 0 ; i < def->ndisks ; i++) {
-                    if (def->disks[i]->type == VIR_DOMAIN_DISK_DEVICE_CDROM &&
-                        STREQ(def->disks[i]->dst, "hdc") &&
-                        def->disks[i]->src) {
-                        virBufferVSprintf(&buf, "(cdrom '%s')",
-                                          def->disks[i]->src);
+            /* some disk devices are defined here */
+            for (i = 0 ; i < def->ndisks ; i++) {
+                switch (def->disks[i]->device) {
+                case VIR_DOMAIN_DISK_DEVICE_CDROM:
+                    /* Only xend <= 3.0.2 wants cdrom config here */
+                    if (xendConfigVersion != 1)
                         break;
-                    }
+                    if (!STREQ(def->disks[i]->dst, "hdc") ||
+                        def->disks[i]->src == NULL)
+                        break;
+
+                    virBufferVSprintf(&buf, "(cdrom '%s')",
+                                      def->disks[i]->src);
+                    break;
+
+                case VIR_DOMAIN_DISK_DEVICE_FLOPPY:
+                    /* all xend versions define floppies here */
+                    virBufferVSprintf(&buf, "(%s '%s')", def->disks[i]->dst,
+                        def->disks[i]->src);
+                    break;
+
+                default:
+                    break;
                 }
             }
 

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