On Tue, Nov 24, 2020 at 02:48:34PM -0500, Matt Coleman wrote:
Co-authored-by: Sri Ramanujam <sramanujam(a)datto.com>
Signed-off-by: Matt Coleman <matt(a)datto.com>
---
src/hyperv/hyperv_driver.c | 51 ++++++++++++++++++++++++++++++++++++++
1 file changed, 51 insertions(+)
diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c
index 559b60d3df..1ad52e598a 100644
--- a/src/hyperv/hyperv_driver.c
+++ b/src/hyperv/hyperv_driver.c
@@ -327,6 +327,53 @@ hypervGetDeviceParentRasdFromDeviceId(const char *parentDeviceId,
}
+static int
+hypervDomainCreateSCSIController(virDomainPtr domain)
+{
+ g_autoptr(GHashTable) scsiResource = NULL;
+ g_autofree char *resourceType = NULL;
+
+ resourceType = g_strdup_printf("%d",
MSVM_RASD_RESOURCETYPE_PARALLEL_SCSI_HBA);
+
+ VIR_DEBUG("Attaching SCSI Controller");
+
+ /* prepare embedded param */
+ scsiResource =
hypervCreateEmbeddedParam(Msvm_ResourceAllocationSettingData_WmiInfo);
+ if (!scsiResource)
+ return -1;
+
+ if (hypervSetEmbeddedProperty(scsiResource, "ResourceType", resourceType)
< 0)
+ return -1;
+
+ if (hypervSetEmbeddedProperty(scsiResource, "ResourceSubType",
+ "Microsoft:Hyper-V:Synthetic SCSI
Controller") < 0)
+ return -1;
+
+ /* perform the settings change */
+ if (hypervMsvmVSMSAddResourceSettings(domain, &scsiResource,
+ Msvm_ResourceAllocationSettingData_WmiInfo,
NULL) < 0)
+ return -1;
+
+ return 0;
+}
+
+
+static int
+hypervDomainAttachStorage(virDomainPtr domain, virDomainDefPtr def)
+{
+ size_t i = 0;
+
+ for (i = 0; i < def->ncontrollers; i++) {
+ if (def->controllers[i]->type != VIR_DOMAIN_CONTROLLER_TYPE_SCSI)
+ continue;
+
+ if (hypervDomainCreateSCSIController(domain) < 0)
+ return -1;
You ought to pass def->controllers[i] into this method and validate
as many properties as practical. At very least validate the model
and report VIR_ERR_CONFIG_UNSUPPORTED for any you can't emulate.
Probably ought to reject any info->type which is not
VIR_DOMAIN_ADDRESS_TYPE_NONE, since you're not attempting todo
any device addressing at this time.
+ }
+
+ return 0;
+}
+
/*
* Functions for deserializing device entries
@@ -2003,6 +2050,10 @@ hypervDomainDefineXML(virConnectPtr conn, const char *xml)
if (def->mem.cur_balloon > 0 && hypervDomainSetMemory(domain,
def->mem.cur_balloon) < 0)
goto error;
+ /* attach all storage */
+ if (hypervDomainAttachStorage(domain, def) < 0)
+ goto error;
+
return domain;
error:
--
2.27.0
Regards,
Daniel
--
|:
https://berrange.com -o-
https://www.flickr.com/photos/dberrange :|
|:
https://libvirt.org -o-
https://fstop138.berrange.com :|
|:
https://entangle-photo.org -o-
https://www.instagram.com/dberrange :|