[PATCH 11/16] qemu: Implement the device parse callback and use it for interfaces

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

 



This patch implements the callback that is used to fill the qemu default
network card into the XML if none is provided in the definition.
---
 src/qemu/qemu_conf.c   |  1 +
 src/qemu/qemu_domain.c | 23 +++++++++++++++++++++++
 src/qemu/qemu_domain.h |  1 +
 3 files changed, 25 insertions(+)

diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index a2a05d4..cc6a738 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -556,6 +556,7 @@ virCapsPtr virQEMUDriverCreateCapabilities(virQEMUDriverPtr driver)

     qemuDomainSetPrivateDataHooks(caps);
     qemuDomainSetNamespaceHooks(caps);
+    qemuDomainSetDefHooks(caps);

     if (virGetHostUUID(caps->host.host_uuid)) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 482f64a..7c8768b 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -633,6 +633,24 @@ qemuDomainDefNamespaceFormatXML(virBufferPtr buf,
     return 0;
 }

+
+static int
+qemuDomainDeviceDefCallback(void *device)
+{
+    virDomainDeviceDefPtr dev = device;
+
+    if (dev->type == VIR_DOMAIN_DEVICE_NET) {
+        if (!dev->data.net->model) {
+            if (!(dev->data.net->model = strdup("rtl8139"))) {
+                virReportOOMError();
+                return -1;
+            }
+        }
+    }
+    return 0;
+}
+
+
 static const char *
 qemuDomainDefNamespaceHref(void)
 {
@@ -659,6 +677,11 @@ void qemuDomainSetNamespaceHooks(virCapsPtr caps)
     caps->ns.href = qemuDomainDefNamespaceHref;
 }

+void qemuDomainSetDefHooks(virCapsPtr caps)
+{
+    caps->virDriverDeviceDefCallback = qemuDomainDeviceDefCallback;
+}
+
 static void
 qemuDomainObjSaveJob(virQEMUDriverPtr driver, virDomainObjPtr obj)
 {
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index 905b099..210cffd 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -180,6 +180,7 @@ void qemuDomainEventQueue(virQEMUDriverPtr driver,

 void qemuDomainSetPrivateDataHooks(virCapsPtr caps);
 void qemuDomainSetNamespaceHooks(virCapsPtr caps);
+void qemuDomainSetDefHooks(virCapsPtr caps);

 int qemuDomainObjBeginJob(virQEMUDriverPtr driver,
                           virDomainObjPtr obj,
-- 
1.8.1.1

--
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]