
# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1260583468 28800 # Node ID 2e80fd8fdbc575decc0b8a1623f8b9ad9122dccf # Parent b7bb0916ce5f3e6b70b4ff666160e076bfd8783a (#2) Add template RASD for floppy devices Use VIRT_DISK_TYPE_FLOPPY (etc) value for determining the emulated type in set_disk_props(). Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r b7bb0916ce5f -r 2e80fd8fdbc5 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 @@ -806,11 +806,13 @@ (CMPIValue *)"FV disk", CMPI_chars); } - if (emu_type == 0) { + if (emu_type == VIRT_DISK_TYPE_DISK) { CMSetProperty(inst, "VirtualQuantity", (CMPIValue *)&disk_size, CMPI_uint64); - } else if (emu_type == 1) { + } else if (emu_type == VIRT_DISK_TYPE_CDROM) { dev = "hdc"; + } else if (emu_type == VIRT_DISK_TYPE_FLOPPY) { + 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);