]> xenbits.xensource.com Git - libvirt.git/commitdiff
hyperv: XML parsing of serial ports
authorMatt Coleman <mcoleman@datto.com>
Tue, 2 Feb 2021 00:48:36 +0000 (19:48 -0500)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 2 Feb 2021 08:36:27 +0000 (09:36 +0100)
Co-authored-by: Sri Ramanujam <sramanujam@datto.com>
Signed-off-by: Matt Coleman <matt@datto.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/hyperv/hyperv_driver.c
src/hyperv/hyperv_wmi.c
src/hyperv/hyperv_wmi.h
src/hyperv/hyperv_wmi_classes.h
src/hyperv/hyperv_wmi_generator.input

index bdc084790ad08c9366420ae53e8b9f5d8e54422f..9a603dc621944ff72f9a16b9276860936bf57a1c 100644 (file)
@@ -1253,6 +1253,52 @@ hypervDomainDefParseStorage(hypervPrivate *priv,
 }
 
 
+static int
+hypervDomainDefParseSerial(virDomainDefPtr def, Msvm_ResourceAllocationSettingData *rasd)
+{
+    for (; rasd; rasd = rasd->next) {
+        int port_num = 0;
+        char **conn = NULL;
+        const char *srcPath = NULL;
+        virDomainChrDefPtr serial = NULL;
+
+        if (rasd->data->ResourceType != MSVM_RASD_RESOURCETYPE_SERIAL_PORT)
+            continue;
+
+        /* get port number */
+        port_num = rasd->data->ElementName[4] - '0';
+        if (port_num < 1) {
+            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;
+        }
+    }
+
+    return 0;
+}
+
 
 /*
  * Driver functions
@@ -2113,6 +2159,8 @@ hypervDomainGetXMLDesc(virDomainPtr domain, unsigned int flags)
     g_autoptr(Msvm_MemorySettingData) memorySettingData = NULL;
     g_autoptr(Msvm_ResourceAllocationSettingData) rasd = NULL;
     g_autoptr(Msvm_StorageAllocationSettingData) sasd = NULL;
+    g_autoptr(Msvm_SerialPortSettingData) spsd = NULL;
+    Msvm_ResourceAllocationSettingData *serialDevices = NULL;
 
     virCheckFlags(VIR_DOMAIN_XML_COMMON_FLAGS, NULL);
 
@@ -2151,6 +2199,9 @@ hypervDomainGetXMLDesc(virDomainPtr domain, unsigned int flags)
         return NULL;
     }
 
+    if (hypervGetSerialPortSD(priv, virtualSystemSettingData->data->InstanceID, &spsd) < 0)
+        return NULL;
+
     /* Fill struct */
     def->virtType = VIR_DOMAIN_VIRT_HYPERV;
 
@@ -2215,6 +2266,14 @@ hypervDomainGetXMLDesc(virDomainPtr domain, unsigned int flags)
     if (hypervDomainDefParseStorage(priv, def, rasd, sasd) < 0)
         return NULL;
 
+    if (g_str_has_prefix(priv->version, "6."))
+        serialDevices = rasd;
+    else
+        serialDevices = (Msvm_ResourceAllocationSettingData *)spsd;
+
+    if (hypervDomainDefParseSerial(def, serialDevices) < 0)
+        return NULL;
+
     /* XXX xmlopts must be non-NULL */
     return virDomainDefFormat(def, NULL, virDomainDefFormatConvertXMLFlags(flags));
 }
index a28bb0e815ecd38409f32bf62aa082cf9eaa90ef..f5f07976057842eeab6e166e897177b66b22e115 100644 (file)
@@ -1488,6 +1488,16 @@ hypervGetStorageAllocationSD(hypervPrivate *priv,
 }
 
 
+int
+hypervGetSerialPortSD(hypervPrivate *priv,
+                      const char *id,
+                      Msvm_SerialPortSettingData **data)
+{
+    hypervGetSettingData(Msvm_SerialPortSettingData, id, data);
+    return 0;
+}
+
+
 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  * Msvm_VirtualSystemManagementService
  */
index f09948895edae60efeeefdaa2efc77c43d72f38d..2b0d0e4a3f89050a995331eb40c77d30a5b9b8e5 100644 (file)
@@ -254,6 +254,10 @@ int hypervGetStorageAllocationSD(hypervPrivate *priv,
                                  const char *id,
                                  Msvm_StorageAllocationSettingData **data);
 
+int hypervGetSerialPortSD(hypervPrivate *priv,
+                          const char *id,
+                          Msvm_SerialPortSettingData **data);
+
 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  * Msvm_VirtualSystemManagementService
  */
index 2c03ca3745f7b7f2af9c5f5e54182e7b23bc96b6..2f813bedb37ea1b33912e5caa0efd0cc99c33eaf 100644 (file)
@@ -113,6 +113,7 @@ enum _Msvm_ResourceAllocationSettingData_ResourceType {
     MSVM_RASD_RESOURCETYPE_DVD_DRIVE = 16,
     MSVM_RASD_RESOURCETYPE_DISK_DRIVE = 17,
     MSVM_RASD_RESOURCETYPE_STORAGE_EXTENT = 19,
+    MSVM_RASD_RESOURCETYPE_SERIAL_PORT = 21,
     MSVM_RASD_RESOURCETYPE_LOGICAL_DISK = 31,
 };
 
index e1b4fd3f9f6aa40d134b59edc8756775b4a009f7..765ffba169704221e746db248f3dddf7a33feacf 100644 (file)
@@ -629,6 +629,11 @@ class Msvm_ResourceAllocationSettingData
 end
 
 
+class Msvm_SerialPortSettingData : Msvm_ResourceAllocationSettingData
+    boolean  DebuggerMode
+end
+
+
 class Msvm_Keyboard
     string   InstanceID
     string   Caption