On 2/2/21 1:48 AM, Matt Coleman wrote:
Co-authored-by: Sri Ramanujam <sramanujam@xxxxxxxxx>
Signed-off-by: Matt Coleman <matt@xxxxxxxxx>
---
src/hyperv/hyperv_driver.c | 61 +++++++++++++++++++++++++++
src/hyperv/hyperv_wmi.c | 10 +++++
src/hyperv/hyperv_wmi.h | 4 ++
src/hyperv/hyperv_wmi_classes.h | 1 +
src/hyperv/hyperv_wmi_generator.input | 5 +++
5 files changed, 81 insertions(+)
diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c
index bdc084790a..9902fa75b8 100644
--- a/src/hyperv/hyperv_driver.c
+++ b/src/hyperv/hyperv_driver.c
@@ -1253,6 +1253,54 @@ hypervDomainDefParseStorage(hypervPrivate *priv,
}
+static int
+hypervDomainDefParseSerial(virDomainDefPtr def, Msvm_ResourceAllocationSettingData *rasd)
+{
+ while (rasd) {
+ if (rasd->data->ResourceType == MSVM_RASD_RESOURCETYPE_SERIAL_PORT) {
I think we can save one level of indendation if this was:
if (rasd->data->ResourceType != MSVM_RASD_RESOURCETYPE_SERIAL_PORT) {
rasd = rasd->next;
continue;
}
and to avoid having to advance pointer in every path, let's just use
for() loop. Sorry for not spotting this earlier. I'll fix this locally
before pushing.
+ int port_num = 0;
+ char **conn = NULL;
+ const char *srcPath = NULL;
+ virDomainChrDefPtr serial = NULL;
+
+ /* get port number */
+ port_num = rasd->data->ElementName[4] - '0';
+ if (port_num < 1) {
+ rasd = rasd->next;
+ continue;
+ }
+
+ serial = virDomainChrDefNew(NULL);
+
+ serial->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL;
+ serial->source->type = VIR_DOMAIN_CHR_TYPE_PIPE;
+ serial->target.port = port_num;
+
+ /* set up source */
+ if (rasd->data->Connection.count < 1) {
+ srcPath = "-1";
+ } else {
+ conn = rasd->data->Connection.data;
+ if (!*conn)
+ srcPath = "-1";
+ else
+ srcPath = *conn;
+ }
+
+ serial->source->data.file.path = g_strdup(srcPath);
+
+ if (VIR_APPEND_ELEMENT(def->serials, def->nserials, serial) < 0) {
+ virDomainChrDefFree(serial);
+ return -1;
+ }
+ }
+
+ rasd = rasd->next;
+ }
+
+ return 0;
+}
+
Michal