mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
hyperv: attach floppy disks when defining domains
Co-authored-by: Sri Ramanujam <sramanujam@datto.com> Signed-off-by: Matt Coleman <matt@datto.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
91b3725099
commit
fdc0222095
@ -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
|
static int
|
||||||
hypervDomainAttachStorageVolume(virDomainPtr domain,
|
hypervDomainAttachStorageVolume(virDomainPtr domain,
|
||||||
virDomainDiskDefPtr disk,
|
virDomainDiskDefPtr disk,
|
||||||
@ -807,6 +854,7 @@ hypervDomainAttachStorage(virDomainPtr domain, virDomainDefPtr def, const char *
|
|||||||
Msvm_ResourceAllocationSettingData *entry = NULL;
|
Msvm_ResourceAllocationSettingData *entry = NULL;
|
||||||
Msvm_ResourceAllocationSettingData *ideChannels[HYPERV_MAX_IDE_CHANNELS];
|
Msvm_ResourceAllocationSettingData *ideChannels[HYPERV_MAX_IDE_CHANNELS];
|
||||||
Msvm_ResourceAllocationSettingData *scsiControllers[HYPERV_MAX_SCSI_CONTROLLERS];
|
Msvm_ResourceAllocationSettingData *scsiControllers[HYPERV_MAX_SCSI_CONTROLLERS];
|
||||||
|
Msvm_ResourceAllocationSettingData *floppySettings = NULL;
|
||||||
|
|
||||||
/* start with attaching scsi controllers */
|
/* start with attaching scsi controllers */
|
||||||
for (i = 0; i < def->ncontrollers; i++) {
|
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;
|
ideChannels[entry->data->Address[0] - '0'] = entry;
|
||||||
else if (entry->data->ResourceType == MSVM_RASD_RESOURCETYPE_PARALLEL_SCSI_HBA)
|
else if (entry->data->ResourceType == MSVM_RASD_RESOURCETYPE_PARALLEL_SCSI_HBA)
|
||||||
scsiControllers[num_scsi_controllers++] = entry;
|
scsiControllers[num_scsi_controllers++] = entry;
|
||||||
|
else if (entry->data->ResourceType == MSVM_RASD_RESOURCETYPE_DISKETTE_DRIVE)
|
||||||
|
floppySettings = entry;
|
||||||
|
|
||||||
entry = entry->next;
|
entry = entry->next;
|
||||||
}
|
}
|
||||||
@ -853,6 +903,10 @@ hypervDomainAttachStorage(virDomainPtr domain, virDomainDefPtr def, const char *
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case VIR_DOMAIN_DISK_BUS_FDC:
|
||||||
|
if (hypervDomainAttachFloppy(domain, def->disks[i], floppySettings, hostname) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Unsupported controller type"));
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Unsupported controller type"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user