[Libvirt-cim] [PATCH 2 of 2] Add template RASD for floppy devices

Kaitlin Rupert kaitlin at linux.vnet.ibm.com
Sat Dec 12 02:06:49 UTC 2009


# HG changeset patch
# User Kaitlin Rupert <karupert at us.ibm.com>
# Date 1260583468 28800
# Node ID e9f73b7c78fdde79996eb6a3a54cf56219153cc0
# Parent  b7bb0916ce5f3e6b70b4ff666160e076bfd8783a
Add template RASD for floppy devices

Signed-off-by: Kaitlin Rupert <karupert at us.ibm.com>

diff -r b7bb0916ce5f -r e9f73b7c78fd src/Virt_SettingsDefineCapabilities.c
--- a/src/Virt_SettingsDefineCapabilities.c	Fri Dec 11 18:04:28 2009 -0800
+++ b/src/Virt_SettingsDefineCapabilities.c	Fri Dec 11 18:04:28 2009 -0800
@@ -811,6 +811,8 @@
                                       (CMPIValue *)&disk_size, CMPI_uint64);
                 } else if (emu_type == 1) {
                         dev = "hdc";
+                } else if (emu_type == 1) {
+                        dev = "fda";
                 }
 
                 CMSetProperty(inst, "VirtualDevice",
@@ -825,29 +827,36 @@
         return s;
 }
 
-static CMPIStatus cdrom_template(const CMPIObjectPath *ref,
-                                  int template_type,
-                                  struct inst_list *list)
+static CMPIStatus cdrom_or_floppy_template(const CMPIObjectPath *ref,
+                                           int template_type,
+                                           uint16_t emu_type,
+                                           struct inst_list *list)
 {
         char *pfx = NULL;
         const char *id;
         const char *vol_path = "/dev/null";
         uint64_t vol_size = 0;
         CMPIStatus s = {CMPI_RC_OK, NULL};
-        uint16_t emu_type = 1;
+        const char *dev_str = NULL;
+        char *id_str = NULL;
+
+        if (emu_type == VIRT_DISK_TYPE_CDROM)
+                dev_str = "CDROM";
+        else
+                dev_str = "floppy";
 
         switch(template_type) {
         case SDC_RASD_MIN:
-                id = "Minimum CDROM";
+                id = "Minimum";
                 break;
         case SDC_RASD_MAX:
-                id = "Maximum CDROM";
+                id = "Maximum";
                 break;
         case SDC_RASD_INC:
-                id = "Increment CDROM";
+                id = "Increment";
                 break;
         case SDC_RASD_DEF:
-                id = "Default CDROM";
+                id = "Default";
                 break;
         default:
                 cu_statusf(_BROKER, &s,
@@ -856,6 +865,13 @@
                 goto out;
         }
 
+        if (asprintf(&id_str, "%s %s", id, dev_str) == -1) {
+                cu_statusf(_BROKER, &s,
+                           CMPI_RC_ERR_NOT_FOUND,
+                           "Unable to build disk device caption");
+                goto out;
+        }
+
         pfx = class_prefix_name(CLASSNAME(ref));
         if (STREQ(pfx, "Xen")) {
                 int xen_type[2] = {DOMAIN_XENFV, DOMAIN_XENPV};
@@ -864,7 +880,7 @@
                 for (; i < 2; i++) {
                         s = set_disk_props(xen_type[i],
                                            ref, 
-                                           id,
+                                           id_str,
                                            vol_path, 
                                            vol_size, 
                                            emu_type, 
@@ -873,7 +889,7 @@
         } else if (STREQ(pfx, "KVM")) {
                 s = set_disk_props(DOMAIN_KVM,
                                    ref, 
-                                   id,
+                                   id_str,
                                    vol_path, 
                                    vol_size, 
                                    emu_type, 
@@ -887,6 +903,7 @@
 
  out:
         free(pfx);
+        free(id_str);
 
         return s;
 }
@@ -1305,7 +1322,17 @@
                         goto out;            
         }
 
-        s = cdrom_template(ref, template_type, list);
+        s = cdrom_or_floppy_template(ref, 
+                                     template_type, 
+                                     VIRT_DISK_TYPE_CDROM, 
+                                     list);
+        if (s.rc != CMPI_RC_OK)
+                goto out;            
+
+        s = cdrom_or_floppy_template(ref, 
+                                     template_type, 
+                                     VIRT_DISK_TYPE_FLOPPY, 
+                                     list);
 
  out:
         free(pfx); 
@@ -1334,7 +1361,17 @@
         if (STREQ(pfx, "LXC"))
                 goto out;
 
-        s = cdrom_template(ref, template_type, list);
+        s = cdrom_or_floppy_template(ref, 
+                                     template_type, 
+                                     VIRT_DISK_TYPE_CDROM, 
+                                     list);
+        if (s.rc != CMPI_RC_OK)
+                goto out;
+
+        s = cdrom_or_floppy_template(ref, 
+                                     template_type, 
+                                     VIRT_DISK_TYPE_FLOPPY, 
+                                     list);
 
  out:
         free(pfx);




More information about the Libvirt-cim mailing list