bhyve: add virBhyveDriverCreateXMLConf

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.
This commit is contained in:
Roman Bogorodskiy 2017-01-05 16:31:35 +04:00
parent 20a7737d35
commit 13a050b2c3
27 changed files with 38 additions and 5 deletions

View 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,

View File

@ -37,6 +37,8 @@ struct _bhyveDomainObjPrivate {
bhyveMonitorPtr mon;
};
virDomainXMLOptionPtr virBhyveDriverCreateXMLConf(bhyveConnPtr);
extern virDomainXMLPrivateDataCallbacks virBhyveDriverPrivateDataCallbacks;
extern virDomainDefParserConfig virBhyveDriverDomainDefParserConfig;

View 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()))

View 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) \

View 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'/>

View 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'/>

View 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'/>

View 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'/>

View 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'/>

View 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'/>

View 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'/>

View 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'/>

View 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'/>

View 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'/>

View 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'/>

View 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'/>

View 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'/>

View 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'/>

View 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'/>

View 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'/>

View 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'/>

View 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'/>

View 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'/>

View 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'/>

View 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'/>

View 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'/>

View 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) \