]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
bhyve: add virBhyveDriverCreateXMLConf
authorRoman Bogorodskiy <bogorodskiy@gmail.com>
Thu, 5 Jan 2017 12:31:35 +0000 (16:31 +0400)
committerRoman Bogorodskiy <bogorodskiy@gmail.com>
Mon, 30 Jan 2017 16:48:42 +0000 (20:48 +0400)
Add virBhyveDriverCreateXMLConf, a simple wrapper around
virDomainXMLOptionNew that makes it easier to pass bhyveConnPtr
as a private data for parser. It will be used later for device
address allocation at parsing time.

Update consumers to use it instead of direct calls to
virDomainXMLOptionNew.

As we now have proper callbacks connected for the tests, update
test files accordingly to include the automatically generated
PCI root controller.

27 files changed:
src/bhyve/bhyve_domain.c
src/bhyve/bhyve_domain.h
src/bhyve/bhyve_driver.c
tests/bhyvexml2argvtest.c
tests/bhyvexml2xmloutdata/bhyvexml2xmlout-acpiapic.xml
tests/bhyvexml2xmloutdata/bhyvexml2xmlout-base.xml
tests/bhyvexml2xmloutdata/bhyvexml2xmlout-bhyveload-bootorder.xml
tests/bhyvexml2xmloutdata/bhyvexml2xmlout-bhyveload-bootorder1.xml
tests/bhyvexml2xmloutdata/bhyvexml2xmlout-bhyveload-bootorder2.xml
tests/bhyvexml2xmloutdata/bhyvexml2xmlout-bhyveload-bootorder3.xml
tests/bhyvexml2xmloutdata/bhyvexml2xmlout-bhyveload-bootorder4.xml
tests/bhyvexml2xmloutdata/bhyvexml2xmlout-bhyveload-explicitargs.xml
tests/bhyvexml2xmloutdata/bhyvexml2xmlout-console.xml
tests/bhyvexml2xmloutdata/bhyvexml2xmlout-custom-loader.xml
tests/bhyvexml2xmloutdata/bhyvexml2xmlout-disk-cdrom-grub.xml
tests/bhyvexml2xmloutdata/bhyvexml2xmlout-disk-cdrom.xml
tests/bhyvexml2xmloutdata/bhyvexml2xmlout-disk-virtio.xml
tests/bhyvexml2xmloutdata/bhyvexml2xmlout-grub-bootorder.xml
tests/bhyvexml2xmloutdata/bhyvexml2xmlout-grub-bootorder2.xml
tests/bhyvexml2xmloutdata/bhyvexml2xmlout-grub-defaults.xml
tests/bhyvexml2xmloutdata/bhyvexml2xmlout-localtime.xml
tests/bhyvexml2xmloutdata/bhyvexml2xmlout-macaddr.xml
tests/bhyvexml2xmloutdata/bhyvexml2xmlout-metadata.xml
tests/bhyvexml2xmloutdata/bhyvexml2xmlout-serial-grub-nocons.xml
tests/bhyvexml2xmloutdata/bhyvexml2xmlout-serial-grub.xml
tests/bhyvexml2xmloutdata/bhyvexml2xmlout-serial.xml
tests/bhyvexml2xmltest.c

index e2a20ce63d5f67c471225d610ab914f9b9c295ba..b4dc26767c1e907f620b32d95946186109bf91a3 100644 (file)
@@ -83,6 +83,15 @@ bhyveDomainDeviceDefPostParse(virDomainDeviceDefPtr dev ATTRIBUTE_UNUSED,
     return 0;
 }
 
+virDomainXMLOptionPtr
+virBhyveDriverCreateXMLConf(bhyveConnPtr driver)
+{
+    virBhyveDriverDomainDefParserConfig.priv = driver;
+    return virDomainXMLOptionNew(&virBhyveDriverDomainDefParserConfig,
+                                 &virBhyveDriverPrivateDataCallbacks,
+                                 NULL);
+}
+
 virDomainDefParserConfig virBhyveDriverDomainDefParserConfig = {
     .devicesPostParseCallback = bhyveDomainDeviceDefPostParse,
     .domainPostParseCallback = bhyveDomainDefPostParse,
index 0a60392166367bee377ac209c2471a544e579538..bbc8ecd8cf2b20f3c044640e3f800817ea997d4b 100644 (file)
@@ -37,6 +37,8 @@ struct _bhyveDomainObjPrivate {
     bhyveMonitorPtr mon;
 };
 
+virDomainXMLOptionPtr virBhyveDriverCreateXMLConf(bhyveConnPtr);
+
 extern virDomainXMLPrivateDataCallbacks virBhyveDriverPrivateDataCallbacks;
 extern virDomainDefParserConfig virBhyveDriverDomainDefParserConfig;
 
index e42ec479eb4dd781e295f3665c317898b76dcdbe..f4ccef32bfe26bba48721626ceed35cddfa652e0 100644 (file)
@@ -1246,9 +1246,7 @@ bhyveStateInitialize(bool privileged,
     if (virBhyveProbeGrubCaps(&bhyve_driver->grubcaps) < 0)
         goto cleanup;
 
-    if (!(bhyve_driver->xmlopt = virDomainXMLOptionNew(&virBhyveDriverDomainDefParserConfig,
-                                                       &virBhyveDriverPrivateDataCallbacks,
-                                                       NULL)))
+    if (!(bhyve_driver->xmlopt = virBhyveDriverCreateXMLConf(bhyve_driver)))
         goto cleanup;
 
     if (!(bhyve_driver->domains = virDomainObjListNew()))
index 22a902c53d41ef096c6c9c920c2695f28cb84b58..a615c8ca146fcf97201ed5805a26a5eaa0285573 100644 (file)
@@ -7,6 +7,7 @@
 # include "datatypes.h"
 
 # include "bhyve/bhyve_capabilities.h"
+# include "bhyve/bhyve_domain.h"
 # include "bhyve/bhyve_utils.h"
 # include "bhyve/bhyve_command.h"
 
@@ -131,7 +132,7 @@ mymain(void)
     if ((driver.caps = virBhyveCapsBuild()) == NULL)
         return EXIT_FAILURE;
 
-    if ((driver.xmlopt = virDomainXMLOptionNew(NULL, NULL, NULL)) == NULL)
+    if ((driver.xmlopt = virBhyveDriverCreateXMLConf(&driver)) == NULL)
         return EXIT_FAILURE;
 
 # define DO_TEST_FULL(name, flags)                             \
index b4720ecaffae656c0dce55d3a3417a379d7440a0..ef57e0be69a811162ffaa08c45701ae16c00d264 100644 (file)
@@ -23,6 +23,7 @@
       <target dev='hda' bus='sata'/>
       <address type='drive' controller='0' bus='0' target='2' unit='0'/>
     </disk>
+    <controller type='pci' index='0' model='pci-root'/>
     <controller type='sata' index='0'/>
     <interface type='bridge'>
       <mac address='52:54:00:81:c4:b1'/>
index cd4e4f80d1f511f5ad0409015add899956bf06f5..0ff1a3c6b3d3c389f092b7531bf4eaade5b658a6 100644 (file)
@@ -19,6 +19,7 @@
       <target dev='hda' bus='sata'/>
       <address type='drive' controller='0' bus='0' target='2' unit='0'/>
     </disk>
+    <controller type='pci' index='0' model='pci-root'/>
     <controller type='sata' index='0'/>
     <interface type='bridge'>
       <mac address='52:54:00:b9:94:02'/>
index ab01cb5ab26711d6587077360cc77d2c80985398..6c092bb8d418c3aaf2ad57e143d1cc5ec564a092 100644 (file)
@@ -26,6 +26,7 @@
       <readonly/>
       <address type='drive' controller='0' bus='0' target='4' unit='0'/>
     </disk>
+    <controller type='pci' index='0' model='pci-root'/>
     <controller type='sata' index='0'/>
     <interface type='bridge'>
       <mac address='52:54:00:8d:10:e1'/>
index df69c4e879394752cc1b13b6c83419bcb7b9d031..f9e55d6e3367cfb9ca7cf8cc786c0d734da16f06 100644 (file)
@@ -26,6 +26,7 @@
       <readonly/>
       <address type='drive' controller='0' bus='0' target='4' unit='0'/>
     </disk>
+    <controller type='pci' index='0' model='pci-root'/>
     <controller type='sata' index='0'/>
     <interface type='bridge'>
       <mac address='52:54:00:92:68:0e'/>
index 89131dc85aef758a7226508b4150e718a349d136..f75471f8491f20ab67bf13da06362fbf95fb8ba7 100644 (file)
@@ -19,6 +19,7 @@
       <target dev='hda' bus='sata'/>
       <address type='drive' controller='0' bus='0' target='2' unit='0'/>
     </disk>
+    <controller type='pci' index='0' model='pci-root'/>
     <controller type='sata' index='0'/>
     <interface type='bridge'>
       <mac address='52:54:00:1e:63:25'/>
index 96f9dc4dd06eafd9a21001ca9f4620d55e9d16ad..8b9aeea1860656936bf44d9e87e168f3e2d94b26 100644 (file)
@@ -26,6 +26,7 @@
       <boot order='1'/>
       <address type='drive' controller='0' bus='0' target='4' unit='0'/>
     </disk>
+    <controller type='pci' index='0' model='pci-root'/>
     <controller type='sata' index='0'/>
     <interface type='bridge'>
       <mac address='52:54:00:7a:f5:a4'/>
index 1dd180bc0e9c74ae99ca83d85a29f918d19f2616..a688d8a76fc2ebc7049a3abd9d0c5123154f611f 100644 (file)
@@ -27,6 +27,7 @@
       <boot order='1'/>
       <address type='drive' controller='0' bus='0' target='4' unit='0'/>
     </disk>
+    <controller type='pci' index='0' model='pci-root'/>
     <controller type='sata' index='0'/>
     <interface type='bridge'>
       <mac address='52:54:00:fe:97:82'/>
index d7743a640800b7d89374a43913b3585013c1bf94..bb7193037221855fe32e6933d8bd4f0d7021f744 100644 (file)
@@ -19,6 +19,7 @@
       <target dev='hda' bus='sata'/>
       <address type='drive' controller='0' bus='0' target='2' unit='0'/>
     </disk>
+    <controller type='pci' index='0' model='pci-root'/>
     <controller type='sata' index='0'/>
     <interface type='bridge'>
       <mac address='52:54:00:11:bd:26'/>
index bf926f96b1c976734a5b94c73e39526f02afd3c5..bf9d6ad8af29aa270ce367a0b7601e34e97e364c 100644 (file)
@@ -19,6 +19,7 @@
       <target dev='hda' bus='sata'/>
       <address type='drive' controller='0' bus='0' target='2' unit='0'/>
     </disk>
+    <controller type='pci' index='0' model='pci-root'/>
     <controller type='sata' index='0'/>
     <interface type='bridge'>
       <mac address='52:54:00:b1:42:eb'/>
index 3e7f145edc24ee7687be3c89d59d795bfae8696c..53fd6b54b071f64819caa7e729c765d3727d2afd 100644 (file)
@@ -20,6 +20,7 @@
       <target dev='hda' bus='sata'/>
       <address type='drive' controller='0' bus='0' target='2' unit='0'/>
     </disk>
+    <controller type='pci' index='0' model='pci-root'/>
     <controller type='sata' index='0'/>
     <interface type='bridge'>
       <mac address='52:54:00:35:99:c2'/>
index 285842c01c769f9009d8985db68234dbf937b532..acdc4badb5ba5e69b7ed8f5a7448a891e3484e71 100644 (file)
@@ -20,6 +20,7 @@
       <readonly/>
       <address type='drive' controller='0' bus='0' target='2' unit='0'/>
     </disk>
+    <controller type='pci' index='0' model='pci-root'/>
     <controller type='sata' index='0'/>
     <interface type='bridge'>
       <mac address='52:54:00:6f:6a:53'/>
index 02517e4fdfb63a0ec6228d11a446880418390bd7..23f3f6f47484a9c283fc4362aab66c0ffeb00add 100644 (file)
@@ -20,6 +20,7 @@
       <readonly/>
       <address type='drive' controller='0' bus='0' target='2' unit='0'/>
     </disk>
+    <controller type='pci' index='0' model='pci-root'/>
     <controller type='sata' index='0'/>
     <interface type='bridge'>
       <mac address='52:54:00:e3:ec:9b'/>
index 065ae813a30db752087af400ab5a247ba6cf1ceb..d7abb5abcd98fc42d19ca9e54576a3ca2d610e5d 100644 (file)
@@ -19,6 +19,7 @@
       <target dev='vda' bus='virtio'/>
       <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
     </disk>
+    <controller type='pci' index='0' model='pci-root'/>
     <interface type='bridge'>
       <mac address='52:54:00:bc:85:fe'/>
       <source bridge='virbr0'/>
index 939f7ba5895ea918feaf5c1b5985dc8fb61e2718..f36daae10e599223364f5c97b0a21518dd62f780 100644 (file)
@@ -32,6 +32,7 @@
       <boot order='1'/>
       <address type='drive' controller='0' bus='0' target='6' unit='0'/>
     </disk>
+    <controller type='pci' index='0' model='pci-root'/>
     <controller type='sata' index='0'/>
     <interface type='bridge'>
       <mac address='52:54:00:f4:6c:be'/>
index f774411e9fe81ae2e4929d0474c85736f1e41434..825ccd78f40bc855888091cd4f42a24bf50dc04b 100644 (file)
@@ -34,6 +34,7 @@
       <boot order='3'/>
       <address type='drive' controller='0' bus='0' target='6' unit='0'/>
     </disk>
+    <controller type='pci' index='0' model='pci-root'/>
     <controller type='sata' index='0'/>
     <interface type='bridge'>
       <mac address='52:54:00:0e:d2:6f'/>
index 758986b3f89527a06197f4c735734769625a2c71..b7f0a488643988dd04645521f03a61254be80556 100644 (file)
@@ -19,6 +19,7 @@
       <target dev='hda' bus='sata'/>
       <address type='drive' controller='0' bus='0' target='2' unit='0'/>
     </disk>
+    <controller type='pci' index='0' model='pci-root'/>
     <controller type='sata' index='0'/>
     <interface type='bridge'>
       <mac address='52:54:00:ee:f5:79'/>
index 7e08ff9de5e9d75e720d127b5957a62894e9a271..95b01db2fb7d5b36954b2bb8ee05113073dbc236 100644 (file)
@@ -19,6 +19,7 @@
       <target dev='hda' bus='sata'/>
       <address type='drive' controller='0' bus='0' target='2' unit='0'/>
     </disk>
+    <controller type='pci' index='0' model='pci-root'/>
     <controller type='sata' index='0'/>
     <interface type='bridge'>
       <mac address='52:54:00:82:ca:a3'/>
index 4e4e672fcf818509e95c3d76f41ec73174b11df4..842194caa3a66d980ce35d8f86b624ad7e4d30a7 100644 (file)
@@ -19,6 +19,7 @@
       <target dev='hda' bus='sata'/>
       <address type='drive' controller='0' bus='0' target='2' unit='0'/>
     </disk>
+    <controller type='pci' index='0' model='pci-root'/>
     <controller type='sata' index='0'/>
     <interface type='bridge'>
       <mac address='52:54:00:22:ee:11'/>
index 77e18d48c657e35c43bb5580a05ab4d6e8f615fc..b44b6bd9e1ece73ede9b982be52dffedd2290a72 100644 (file)
@@ -23,6 +23,7 @@
       <target dev='hda' bus='sata'/>
       <address type='drive' controller='0' bus='0' target='0' unit='0'/>
     </disk>
+    <controller type='pci' index='0' model='pci-root'/>
     <controller type='sata' index='0'/>
     <interface type='bridge'>
       <mac address='52:54:00:ad:55:51'/>
index a379f12740b5819c93e2bec4d697f7307a992ec5..f4ace3979884da608ebf0999e495e9badaa99d52 100644 (file)
@@ -19,6 +19,7 @@
       <target dev='hda' bus='sata'/>
       <address type='drive' controller='0' bus='0' target='2' unit='0'/>
     </disk>
+    <controller type='pci' index='0' model='pci-root'/>
     <controller type='sata' index='0'/>
     <interface type='bridge'>
       <mac address='52:54:00:a7:cd:5b'/>
index 2864089ae89f4241dd8301ef70d17ab2ef1327c8..f404ee7e3830fbb2a95faf36b4bd27cfc38b0802 100644 (file)
@@ -19,6 +19,7 @@
       <target dev='hda' bus='sata'/>
       <address type='drive' controller='0' bus='0' target='2' unit='0'/>
     </disk>
+    <controller type='pci' index='0' model='pci-root'/>
     <controller type='sata' index='0'/>
     <interface type='bridge'>
       <mac address='52:54:00:f0:72:11'/>
index 954c58acaf85af55193b48806e3177382d078069..d713deaee4066d4076605f981a77d62c41b688ca 100644 (file)
@@ -19,6 +19,7 @@
       <target dev='hda' bus='sata'/>
       <address type='drive' controller='0' bus='0' target='2' unit='0'/>
     </disk>
+    <controller type='pci' index='0' model='pci-root'/>
     <controller type='sata' index='0'/>
     <interface type='bridge'>
       <mac address='52:54:00:4f:f3:5b'/>
index e95cee4b8e8ecdad987a85a3222918ac29d09653..641ddb33e37a104f690ce41e40c0970358f24499 100644 (file)
@@ -5,6 +5,7 @@
 #ifdef WITH_BHYVE
 
 # include "bhyve/bhyve_capabilities.h"
+# include "bhyve/bhyve_domain.h"
 # include "bhyve/bhyve_utils.h"
 
 # define VIR_FROM_THIS VIR_FROM_NONE
@@ -49,7 +50,7 @@ mymain(void)
     if ((driver.caps = virBhyveCapsBuild()) == NULL)
         return EXIT_FAILURE;
 
-    if ((driver.xmlopt = virDomainXMLOptionNew(NULL, NULL, NULL)) == NULL)
+    if ((driver.xmlopt = virBhyveDriverCreateXMLConf(&driver)) == NULL)
         return EXIT_FAILURE;
 
 # define DO_TEST_FULL(name, is_different)                        \