[libvirt] [PATCH 04/34] Add address info to sound, video and watchdog devices

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add the virDomainDeviceAddress information to the sound, video
and watchdog devices. This means all of them gain the new XML
element

  <address .... />

This brings them upto par with disk/net/hostdev devices which
already have address info

* src/conf/domain_conf.h: Add virDomainDeviceAddress to sound,
  video & watchdog device struts.
* src/conf/domain_conf.c: Hook up parsing/formatting for
  virDomainDeviceAddress in sound, video & watchdog devices
* docs/schemas/domain.rng: Associate device address info
  with sound, video & watchdog
---
 docs/schemas/domain.rng |    9 +++++++
 src/conf/domain_conf.c  |   54 +++++++++++++++++++++++++++++++++++++++-------
 src/conf/domain_conf.h  |    3 ++
 3 files changed, 57 insertions(+), 9 deletions(-)

diff --git a/docs/schemas/domain.rng b/docs/schemas/domain.rng
index f426587..dd729c0 100644
--- a/docs/schemas/domain.rng
+++ b/docs/schemas/domain.rng
@@ -907,6 +907,9 @@
           </optional>
         </element>
       </optional>
+      <optional>
+        <ref name="address"/>
+      </optional>
     </element>
   </define>
   <!--
@@ -1043,6 +1046,9 @@
           <value>ac97</value>
         </choice>
       </attribute>
+      <optional>
+        <ref name="address"/>
+      </optional>
     </element>
   </define>
   <define name="watchdog">
@@ -1064,6 +1070,9 @@
           </choice>
         </attribute>
       </optional>
+      <optional>
+        <ref name="address"/>
+      </optional>
     </element>
   </define>
   <define name="parallel">
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index d7b1aa1..27d0613 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -465,6 +465,8 @@ void virDomainSoundDefFree(virDomainSoundDefPtr def)
     if (!def)
         return;
 
+    virDomainDeviceInfoClear(&def->info);
+
     VIR_FREE(def);
 }
 
@@ -473,6 +475,8 @@ void virDomainWatchdogDefFree(virDomainWatchdogDefPtr def)
     if (!def)
         return;
 
+    virDomainDeviceInfoClear(&def->info);
+
     VIR_FREE(def);
 }
 
@@ -481,6 +485,8 @@ void virDomainVideoDefFree(virDomainVideoDefPtr def)
     if (!def)
         return;
 
+    virDomainDeviceInfoClear(&def->info);
+
     VIR_FREE(def->accel);
     VIR_FREE(def);
 }
@@ -2259,8 +2265,8 @@ error:
 static virDomainSoundDefPtr
 virDomainSoundDefParseXML(virConnectPtr conn,
                           const xmlNodePtr node,
-                          int flags ATTRIBUTE_UNUSED) {
-
+                          int flags)
+{
     char *model;
     virDomainSoundDefPtr def;
 
@@ -2276,6 +2282,9 @@ virDomainSoundDefParseXML(virConnectPtr conn,
         goto error;
     }
 
+    if (virDomainDeviceInfoParseXML(conn, node, &def->info, flags) < 0)
+        goto error;
+
 cleanup:
     VIR_FREE(model);
 
@@ -2291,7 +2300,8 @@ error:
 static virDomainWatchdogDefPtr
 virDomainWatchdogDefParseXML(virConnectPtr conn,
                              const xmlNodePtr node,
-                             int flags ATTRIBUTE_UNUSED) {
+                             int flags)
+{
 
     char *model = NULL;
     char *action = NULL;
@@ -2327,6 +2337,9 @@ virDomainWatchdogDefParseXML(virConnectPtr conn,
         }
     }
 
+    if (virDomainDeviceInfoParseXML(conn, node, &def->info, flags) < 0)
+        goto error;
+
 cleanup:
     VIR_FREE (action);
     VIR_FREE (model);
@@ -2439,7 +2452,7 @@ static virDomainVideoDefPtr
 virDomainVideoDefParseXML(virConnectPtr conn,
                           const xmlNodePtr node,
                           virDomainDefPtr dom,
-                          int flags ATTRIBUTE_UNUSED) {
+                          int flags) {
     virDomainVideoDefPtr def;
     xmlNodePtr cur;
     char *type = NULL;
@@ -2499,6 +2512,9 @@ virDomainVideoDefParseXML(virConnectPtr conn,
         def->heads = 1;
     }
 
+    if (virDomainDeviceInfoParseXML(conn, node, &def->info, flags) < 0)
+        goto error;
+
     VIR_FREE(type);
     VIR_FREE(vram);
     VIR_FREE(heads);
@@ -2927,8 +2943,7 @@ virDomainDeviceDefPtr virDomainDeviceDefParse(virConnectPtr conn,
             goto error;
     } else if (xmlStrEqual(node->name, BAD_CAST "watchdog")) {
         dev->type = VIR_DOMAIN_DEVICE_WATCHDOG;
-        if (!(dev->data.watchdog = virDomainWatchdogDefParseXML(conn, node,
-                                                                flags)))
+        if (!(dev->data.watchdog = virDomainWatchdogDefParseXML(conn, node, flags)))
             goto error;
     } else if (xmlStrEqual(node->name, BAD_CAST "video")) {
         dev->type = VIR_DOMAIN_DEVICE_VIDEO;
@@ -3637,7 +3652,7 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn,
     }
     if (n > 0) {
         virDomainWatchdogDefPtr watchdog =
-            virDomainWatchdogDefParseXML (conn, nodes[0], flags);
+            virDomainWatchdogDefParseXML(conn, nodes[0], flags);
         if (!watchdog)
             goto error;
 
@@ -4550,9 +4565,18 @@ virDomainSoundDefFormat(virConnectPtr conn,
         return -1;
     }
 
-    virBufferVSprintf(buf, "    <sound model='%s'/>\n",
+    virBufferVSprintf(buf, "    <sound model='%s'",
                       model);
 
+    if (virDomainDeviceInfoIsSet(&def->info)) {
+        virBufferAddLit(buf, ">\n");
+        if (virDomainDeviceInfoFormat(buf, &def->info) < 0)
+            return -1;
+        virBufferAddLit(buf, "    </sound>\n");
+    } else {
+        virBufferAddLit(buf, "/>\n");
+    }
+
     return 0;
 }
 
@@ -4577,9 +4601,18 @@ virDomainWatchdogDefFormat(virConnectPtr conn,
         return -1;
     }
 
-    virBufferVSprintf(buf, "    <watchdog model='%s' action='%s'/>\n",
+    virBufferVSprintf(buf, "    <watchdog model='%s' action='%s'",
                       model, action);
 
+    if (virDomainDeviceInfoIsSet(&def->info)) {
+        virBufferAddLit(buf, ">\n");
+        if (virDomainDeviceInfoFormat(buf, &def->info) < 0)
+            return -1;
+        virBufferAddLit(buf, "    </watchdog>\n");
+    } else {
+        virBufferAddLit(buf, "/>\n");
+    }
+
     return 0;
 }
 
@@ -4624,6 +4657,9 @@ virDomainVideoDefFormat(virConnectPtr conn,
         virBufferAddLit(buf, "/>\n");
     }
 
+    if (virDomainDeviceInfoFormat(buf, &def->info) < 0)
+        return -1;
+
     virBufferAddLit(buf, "    </video>\n");
 
     return 0;
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index d4de042..0f68864 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -335,6 +335,7 @@ typedef struct _virDomainSoundDef virDomainSoundDef;
 typedef virDomainSoundDef *virDomainSoundDefPtr;
 struct _virDomainSoundDef {
     int model;
+    virDomainDeviceInfo info;
 };
 
 enum virDomainWatchdogModel {
@@ -359,6 +360,7 @@ typedef virDomainWatchdogDef *virDomainWatchdogDefPtr;
 struct _virDomainWatchdogDef {
     int model;
     int action;
+    virDomainDeviceInfo info;
 };
 
 
@@ -388,6 +390,7 @@ struct _virDomainVideoDef {
     unsigned int vram;
     unsigned int heads;
     virDomainVideoAccelDefPtr accel;
+    virDomainDeviceInfo info;
 };
 
 /* 3 possible graphics console modes */
-- 
1.6.5.2

--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]