[PATCH v2 09/10] hyperv: attach floppy disks when defining domains
Matt Coleman
mcoleman at datto.com
Thu Jan 14 13:03:40 UTC 2021
Co-authored-by: Sri Ramanujam <sramanujam at datto.com>
Signed-off-by: Matt Coleman <matt at datto.com>
---
src/hyperv/hyperv_driver.c | 54 ++++++++++++++++++++++++++++++++++++++
1 file changed, 54 insertions(+)
diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c
index 62c23731f9..76ef6e7e7c 100644
--- a/src/hyperv/hyperv_driver.c
+++ b/src/hyperv/hyperv_driver.c
@@ -762,6 +762,53 @@ hypervDomainAttachCDROM(virDomainPtr domain,
}
+static int
+hypervDomainAttachFloppy(virDomainPtr domain,
+ virDomainDiskDefPtr disk,
+ Msvm_ResourceAllocationSettingData *driveSettings,
+ const char *hostname)
+{
+ g_autoptr(GHashTable) volumeResource = NULL;
+ g_autofree char *vhdInstanceIdEscaped = NULL;
+ g_autofree char *vfd__PATH = NULL;
+ g_autofree char *resourceType = NULL;
+
+ resourceType = g_strdup_printf("%d", MSVM_RASD_RESOURCETYPE_LOGICAL_DISK);
+
+ volumeResource = hypervCreateEmbeddedParam(Msvm_ResourceAllocationSettingData_WmiInfo);
+ if (!volumeResource)
+ return -1;
+
+ vhdInstanceIdEscaped = virStringReplace(driveSettings->data->InstanceID, "\\", "\\\\");
+ vfd__PATH = g_strdup_printf("\\\\%s\\Root\\Virtualization\\V2:"
+ "Msvm_ResourceAllocationSettingData.InstanceID=\"%s\"",
+ hostname, vhdInstanceIdEscaped);
+
+ if (!vfd__PATH)
+ return -1;
+
+ if (hypervSetEmbeddedProperty(volumeResource, "Parent", vfd__PATH) < 0)
+ return -1;
+
+ if (hypervSetEmbeddedProperty(volumeResource, "HostResource", disk->src->path) < 0)
+ return -1;
+
+ if (hypervSetEmbeddedProperty(volumeResource, "ResourceType", resourceType) < 0)
+ return -1;
+
+ if (hypervSetEmbeddedProperty(volumeResource, "ResourceSubType",
+ "Microsoft:Hyper-V:Virtual Floppy Disk") < 0)
+ return -1;
+
+ if (hypervMsvmVSMSAddResourceSettings(domain, &volumeResource,
+ Msvm_ResourceAllocationSettingData_WmiInfo,
+ NULL) < 0)
+ return -1;
+
+ return 0;
+}
+
+
static int
hypervDomainAttachStorageVolume(virDomainPtr domain,
virDomainDiskDefPtr disk,
@@ -807,6 +854,7 @@ hypervDomainAttachStorage(virDomainPtr domain, virDomainDefPtr def, const char *
Msvm_ResourceAllocationSettingData *entry = NULL;
Msvm_ResourceAllocationSettingData *ideChannels[HYPERV_MAX_IDE_CHANNELS];
Msvm_ResourceAllocationSettingData *scsiControllers[HYPERV_MAX_SCSI_CONTROLLERS];
+ Msvm_ResourceAllocationSettingData *floppySettings = NULL;
/* start with attaching scsi controllers */
for (i = 0; i < def->ncontrollers; i++) {
@@ -832,6 +880,8 @@ hypervDomainAttachStorage(virDomainPtr domain, virDomainDefPtr def, const char *
ideChannels[entry->data->Address[0] - '0'] = entry;
else if (entry->data->ResourceType == MSVM_RASD_RESOURCETYPE_PARALLEL_SCSI_HBA)
scsiControllers[num_scsi_controllers++] = entry;
+ else if (entry->data->ResourceType == MSVM_RASD_RESOURCETYPE_DISKETTE_DRIVE)
+ floppySettings = entry;
entry = entry->next;
}
@@ -853,6 +903,10 @@ hypervDomainAttachStorage(virDomainPtr domain, virDomainDefPtr def, const char *
goto cleanup;
}
break;
+ case VIR_DOMAIN_DISK_BUS_FDC:
+ if (hypervDomainAttachFloppy(domain, def->disks[i], floppySettings, hostname) < 0)
+ goto cleanup;
+ break;
default:
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Unsupported controller type"));
goto cleanup;
--
2.27.0
More information about the libvir-list
mailing list