[libvirt] [PATCH v1 0/4] bhyve: rework SATA address allocation

This series reworks SATA address allocation in the bhyve driver. While commit messages provide enough details (I hope), there are some general important notes: - currently, sata devices get PCI addresses and this no longer works, so right now bhyve driver fails on any SATA device - While this series fixes SATA devices' addresses (I hope *again*), old Domain XMLs with already generated PCI addresses will not work. Also, it will not work for XMLs where user manually specified PCI address for a disk, though it worked before. This is not good and I'm open for suggestions how to handle that. I'm thinking about writing a tiny Python script that will drop incorrect addresses from domain XMLs. Fabian Freyer (1): bhyve: detect 32 SATA devices per controller support Roman Bogorodskiy (3): bhyve: add virBhyveDriverCreateXMLConf bhyve: fix SATA address allocation bhyve: add tests for SATA address allocation po/POTFILES.in | 1 + src/bhyve/bhyve_capabilities.c | 59 ++++- src/bhyve/bhyve_capabilities.h | 3 +- src/bhyve/bhyve_command.c | 143 +++++++++--- src/bhyve/bhyve_device.c | 33 ++- src/bhyve/bhyve_domain.c | 69 +++++- src/bhyve/bhyve_domain.h | 2 + src/bhyve/bhyve_driver.c | 4 +- .../bhyvexml2argvdata/bhyvexml2argv-acpiapic.args | 4 +- ...bhyvexml2argv-addr-more-than-32-sata-disks.args | 21 ++ ...yvexml2argv-addr-more-than-32-sata-disks.ldargs | 3 + .../bhyvexml2argv-addr-more-than-32-sata-disks.xml | 196 ++++++++++++++++ .../bhyvexml2argv-addr-multiple-sata-disks.args | 9 + .../bhyvexml2argv-addr-multiple-sata-disks.ldargs | 3 + .../bhyvexml2argv-addr-multiple-sata-disks.xml | 31 +++ ...2argv-addr-no32devs-more-than-32-sata-disks.xml | 196 ++++++++++++++++ ...xml2argv-addr-no32devs-multiple-sata-disks.args | 11 + ...l2argv-addr-no32devs-multiple-sata-disks.ldargs | 3 + ...exml2argv-addr-no32devs-multiple-sata-disks.xml | 31 +++ ...yvexml2argv-addr-no32devs-single-sata-disk.args | 9 + ...exml2argv-addr-no32devs-single-sata-disk.ldargs | 3 + ...hyvexml2argv-addr-no32devs-single-sata-disk.xml | 21 ++ .../bhyvexml2argv-addr-single-sata-disk.args | 9 + .../bhyvexml2argv-addr-single-sata-disk.ldargs | 3 + .../bhyvexml2argv-addr-single-sata-disk.xml | 21 ++ tests/bhyvexml2argvdata/bhyvexml2argv-base.args | 4 +- .../bhyvexml2argv-bhyveload-bootorder.args | 5 +- .../bhyvexml2argv-bhyveload-bootorder1.args | 5 +- .../bhyvexml2argv-bhyveload-bootorder3.args | 5 +- .../bhyvexml2argv-bhyveload-explicitargs.args | 4 +- tests/bhyvexml2argvdata/bhyvexml2argv-console.args | 2 +- .../bhyvexml2argv-custom-loader.args | 4 +- .../bhyvexml2argv-disk-cdrom-grub.args | 4 +- .../bhyvexml2argv-disk-cdrom.args | 4 +- .../bhyvexml2argv-grub-bootorder.args | 6 +- .../bhyvexml2argv-grub-bootorder2.args | 6 +- .../bhyvexml2argv-grub-defaults.args | 4 +- .../bhyvexml2argvdata/bhyvexml2argv-localtime.args | 4 +- tests/bhyvexml2argvdata/bhyvexml2argv-macaddr.args | 4 +- .../bhyvexml2argv-serial-grub-nocons.args | 2 +- .../bhyvexml2argv-serial-grub.args | 2 +- tests/bhyvexml2argvdata/bhyvexml2argv-serial.args | 2 +- tests/bhyvexml2argvtest.c | 25 ++- .../bhyvexml2xmlout-acpiapic.xml | 5 +- ...hyvexml2xmlout-addr-more-than-32-sata-disks.xml | 246 +++++++++++++++++++++ .../bhyvexml2xmlout-addr-multiple-sata-disks.xml | 45 ++++ ...ml2xmlout-addr-no32devs-multiple-sata-disks.xml | 51 +++++ ...vexml2xmlout-addr-no32devs-single-sata-disk.xml | 33 +++ .../bhyvexml2xmlout-addr-single-sata-disk.xml | 33 +++ tests/bhyvexml2xmloutdata/bhyvexml2xmlout-base.xml | 5 +- .../bhyvexml2xmlout-bhyveload-bootorder.xml | 5 +- .../bhyvexml2xmlout-bhyveload-bootorder1.xml | 5 +- .../bhyvexml2xmlout-bhyveload-bootorder2.xml | 5 +- .../bhyvexml2xmlout-bhyveload-bootorder3.xml | 5 +- .../bhyvexml2xmlout-bhyveload-bootorder4.xml | 5 +- .../bhyvexml2xmlout-bhyveload-explicitargs.xml | 5 +- .../bhyvexml2xmlout-console.xml | 5 +- .../bhyvexml2xmlout-custom-loader.xml | 5 +- .../bhyvexml2xmlout-disk-cdrom-grub.xml | 5 +- .../bhyvexml2xmlout-disk-cdrom.xml | 5 +- .../bhyvexml2xmlout-disk-virtio.xml | 1 + .../bhyvexml2xmlout-grub-bootorder.xml | 5 +- .../bhyvexml2xmlout-grub-bootorder2.xml | 5 +- .../bhyvexml2xmlout-grub-defaults.xml | 5 +- .../bhyvexml2xmlout-localtime.xml | 5 +- .../bhyvexml2xmlout-macaddr.xml | 5 +- .../bhyvexml2xmlout-metadata.xml | 6 +- .../bhyvexml2xmlout-serial-grub-nocons.xml | 5 +- .../bhyvexml2xmlout-serial-grub.xml | 5 +- .../bhyvexml2xmloutdata/bhyvexml2xmlout-serial.xml | 5 +- tests/bhyvexml2xmltest.c | 42 +++- 71 files changed, 1398 insertions(+), 139 deletions(-) create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-addr-more-than-32-sata-disks.args create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-addr-more-than-32-sata-disks.ldargs create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-addr-more-than-32-sata-disks.xml create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-addr-multiple-sata-disks.args create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-addr-multiple-sata-disks.ldargs create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-addr-multiple-sata-disks.xml create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-addr-no32devs-more-than-32-sata-disks.xml create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-addr-no32devs-multiple-sata-disks.args create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-addr-no32devs-multiple-sata-disks.ldargs create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-addr-no32devs-multiple-sata-disks.xml create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-addr-no32devs-single-sata-disk.args create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-addr-no32devs-single-sata-disk.ldargs create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-addr-no32devs-single-sata-disk.xml create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-addr-single-sata-disk.args create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-addr-single-sata-disk.ldargs create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-addr-single-sata-disk.xml create mode 100644 tests/bhyvexml2xmloutdata/bhyvexml2xmlout-addr-more-than-32-sata-disks.xml create mode 100644 tests/bhyvexml2xmloutdata/bhyvexml2xmlout-addr-multiple-sata-disks.xml create mode 100644 tests/bhyvexml2xmloutdata/bhyvexml2xmlout-addr-no32devs-multiple-sata-disks.xml create mode 100644 tests/bhyvexml2xmloutdata/bhyvexml2xmlout-addr-no32devs-single-sata-disk.xml create mode 100644 tests/bhyvexml2xmloutdata/bhyvexml2xmlout-addr-single-sata-disk.xml -- 2.11.0

From: Fabian Freyer <fabian.freyer@physik.tu-berlin.de> Introduce a BHYVE_CAP_AHCI32SLOT capability that shows if 32 devices per SATA controller are supported, and a bhyveProbeCapsAHCI32Slot function that probes it. --- src/bhyve/bhyve_capabilities.c | 59 +++++++++++++++++++++++++++++++++++------- src/bhyve/bhyve_capabilities.h | 3 ++- 2 files changed, 52 insertions(+), 10 deletions(-) diff --git a/src/bhyve/bhyve_capabilities.c b/src/bhyve/bhyve_capabilities.c index 10c33b9d7..83e3ae1b4 100644 --- a/src/bhyve/bhyve_capabilities.c +++ b/src/bhyve/bhyve_capabilities.c @@ -168,19 +168,13 @@ virBhyveProbeGrubCaps(virBhyveGrubCapsFlags *caps) return ret; } -int -virBhyveProbeCaps(unsigned int *caps) +static int +bhyveProbeCapsRTC_UTC(unsigned int *caps, char *binary) { - char *binary, *help; + char *help; virCommandPtr cmd = NULL; int ret = 0, exit; - binary = virFindFileInPath("bhyve"); - if (binary == NULL) - goto out; - if (!virFileIsExecutable(binary)) - goto out; - cmd = virCommandNew(binary); virCommandAddArg(cmd, "-h"); virCommandSetErrorBuffer(cmd, &help); @@ -195,6 +189,53 @@ virBhyveProbeCaps(unsigned int *caps) out: VIR_FREE(help); virCommandFree(cmd); + return ret; +} + +static int +bhyveProbeCapsAHCI32Slot(unsigned int *caps, char *binary) +{ + char *error; + virCommandPtr cmd = NULL; + int ret = 0, exit; + + cmd = virCommandNew(binary); + virCommandAddArgList(cmd, "-s", "0,ahci", NULL); + virCommandSetErrorBuffer(cmd, &error); + if (virCommandRun(cmd, &exit) < 0) { + ret = -1; + goto out; + } + + if (strstr(error, "pci slot 0:0: unknown device \"ahci\"") == NULL) + *caps |= BHYVE_CAP_AHCI32SLOT; + + out: + VIR_FREE(error); + virCommandFree(cmd); + return ret; +} + + +int +virBhyveProbeCaps(unsigned int *caps) +{ + char *binary; + int ret = 0; + + binary = virFindFileInPath("bhyve"); + if (binary == NULL) + goto out; + if (!virFileIsExecutable(binary)) + goto out; + + if ((ret = bhyveProbeCapsRTC_UTC(caps, binary))) + goto out; + + if ((ret = bhyveProbeCapsAHCI32Slot(caps, binary))) + goto out; + + out: VIR_FREE(binary); return ret; } diff --git a/src/bhyve/bhyve_capabilities.h b/src/bhyve/bhyve_capabilities.h index 8e7646dfa..55581bd68 100644 --- a/src/bhyve/bhyve_capabilities.h +++ b/src/bhyve/bhyve_capabilities.h @@ -37,7 +37,8 @@ typedef enum { } virBhyveGrubCapsFlags; typedef enum { - BHYVE_CAP_RTC_UTC = 1, + BHYVE_CAP_RTC_UTC = 1 << 0, + BHYVE_CAP_AHCI32SLOT = 1 << 1, } virBhyveCapsFlags; int virBhyveProbeGrubCaps(virBhyveGrubCapsFlags *caps); -- 2.11.0

On 01/05/2017 09:46 AM, Roman Bogorodskiy wrote:
From: Fabian Freyer<fabian.freyer@physik.tu-berlin.de>
Introduce a BHYVE_CAP_AHCI32SLOT capability that shows if 32 devices per SATA controller are supported, and a bhyveProbeCapsAHCI32Slot function that probes it. --- src/bhyve/bhyve_capabilities.c | 59 +++++++++++++++++++++++++++++++++++------- src/bhyve/bhyve_capabilities.h | 3 ++- 2 files changed, 52 insertions(+), 10 deletions(-)
diff --git a/src/bhyve/bhyve_capabilities.c b/src/bhyve/bhyve_capabilities.c index 10c33b9d7..83e3ae1b4 100644 --- a/src/bhyve/bhyve_capabilities.c +++ b/src/bhyve/bhyve_capabilities.c @@ -168,19 +168,13 @@ virBhyveProbeGrubCaps(virBhyveGrubCapsFlags *caps) return ret; }
-int -virBhyveProbeCaps(unsigned int *caps) +static int +bhyveProbeCapsRTC_UTC(unsigned int *caps, char *binary) { - char *binary, *help; + char *help; virCommandPtr cmd = NULL; int ret = 0, exit;
- binary = virFindFileInPath("bhyve"); - if (binary == NULL) - goto out; - if (!virFileIsExecutable(binary)) - goto out; - cmd = virCommandNew(binary); virCommandAddArg(cmd, "-h"); virCommandSetErrorBuffer(cmd, &help); @@ -195,6 +189,53 @@ virBhyveProbeCaps(unsigned int *caps) out: VIR_FREE(help); virCommandFree(cmd); + return ret; +} + +static int +bhyveProbeCapsAHCI32Slot(unsigned int *caps, char *binary) +{ + char *error; + virCommandPtr cmd = NULL; + int ret = 0, exit; + + cmd = virCommandNew(binary); + virCommandAddArgList(cmd, "-s", "0,ahci", NULL); + virCommandSetErrorBuffer(cmd, &error);
Too bad there isn't some way you could learn both of these with a single run of the binary.
+ if (virCommandRun(cmd, &exit) < 0) { + ret = -1; + goto out; + } + + if (strstr(error, "pci slot 0:0: unknown device \"ahci\"") == NULL) + *caps |= BHYVE_CAP_AHCI32SLOT;
That seems like a fairly fragile check. Are you certain there aren't older versions where the error string is different? Anyway, lacking any better check, ACK.
+ + out: + VIR_FREE(error); + virCommandFree(cmd); + return ret; +} + + +int +virBhyveProbeCaps(unsigned int *caps) +{ + char *binary; + int ret = 0; + + binary = virFindFileInPath("bhyve"); + if (binary == NULL) + goto out; + if (!virFileIsExecutable(binary)) + goto out; + + if ((ret = bhyveProbeCapsRTC_UTC(caps, binary))) + goto out; + + if ((ret = bhyveProbeCapsAHCI32Slot(caps, binary))) + goto out; + + out: VIR_FREE(binary); return ret; } diff --git a/src/bhyve/bhyve_capabilities.h b/src/bhyve/bhyve_capabilities.h index 8e7646dfa..55581bd68 100644 --- a/src/bhyve/bhyve_capabilities.h +++ b/src/bhyve/bhyve_capabilities.h @@ -37,7 +37,8 @@ typedef enum { } virBhyveGrubCapsFlags;
typedef enum { - BHYVE_CAP_RTC_UTC = 1, + BHYVE_CAP_RTC_UTC = 1 << 0, + BHYVE_CAP_AHCI32SLOT = 1 << 1, } virBhyveCapsFlags;
int virBhyveProbeGrubCaps(virBhyveGrubCapsFlags *caps);

On 24 Jan 2017, at 16:31, Laine Stump wrote:
+ cmd = virCommandNew(binary); + virCommandAddArgList(cmd, "-s", "0,ahci", NULL); + virCommandSetErrorBuffer(cmd, &error);
Too bad there isn't some way you could learn both of these with a single run of the binary.
+ if (virCommandRun(cmd, &exit) < 0) { + ret = -1; + goto out; + } + + if (strstr(error, "pci slot 0:0: unknown device \"ahci\"") == NULL) + *caps |= BHYVE_CAP_AHCI32SLOT;
That seems like a fairly fragile check. Are you certain there aren't older versions where the error string is different?
Anyway, lacking any better check, ACK.
AFAIR there is a patch in the queue for that upstream (https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=210111), but there hasn’t been much movement there.

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. --- src/bhyve/bhyve_domain.c | 9 +++++++++ src/bhyve/bhyve_domain.h | 2 ++ src/bhyve/bhyve_driver.c | 4 +--- tests/bhyvexml2argvtest.c | 3 ++- tests/bhyvexml2xmloutdata/bhyvexml2xmlout-acpiapic.xml | 1 + tests/bhyvexml2xmloutdata/bhyvexml2xmlout-base.xml | 1 + .../bhyvexml2xmloutdata/bhyvexml2xmlout-bhyveload-bootorder.xml | 1 + .../bhyvexml2xmloutdata/bhyvexml2xmlout-bhyveload-bootorder1.xml | 1 + .../bhyvexml2xmloutdata/bhyvexml2xmlout-bhyveload-bootorder2.xml | 1 + .../bhyvexml2xmloutdata/bhyvexml2xmlout-bhyveload-bootorder3.xml | 1 + .../bhyvexml2xmloutdata/bhyvexml2xmlout-bhyveload-bootorder4.xml | 1 + .../bhyvexml2xmlout-bhyveload-explicitargs.xml | 1 + tests/bhyvexml2xmloutdata/bhyvexml2xmlout-console.xml | 1 + tests/bhyvexml2xmloutdata/bhyvexml2xmlout-custom-loader.xml | 1 + tests/bhyvexml2xmloutdata/bhyvexml2xmlout-disk-cdrom-grub.xml | 1 + tests/bhyvexml2xmloutdata/bhyvexml2xmlout-disk-cdrom.xml | 1 + tests/bhyvexml2xmloutdata/bhyvexml2xmlout-disk-virtio.xml | 1 + tests/bhyvexml2xmloutdata/bhyvexml2xmlout-grub-bootorder.xml | 1 + tests/bhyvexml2xmloutdata/bhyvexml2xmlout-grub-bootorder2.xml | 1 + tests/bhyvexml2xmloutdata/bhyvexml2xmlout-grub-defaults.xml | 1 + tests/bhyvexml2xmloutdata/bhyvexml2xmlout-localtime.xml | 1 + tests/bhyvexml2xmloutdata/bhyvexml2xmlout-macaddr.xml | 1 + tests/bhyvexml2xmloutdata/bhyvexml2xmlout-metadata.xml | 1 + tests/bhyvexml2xmloutdata/bhyvexml2xmlout-serial-grub-nocons.xml | 1 + tests/bhyvexml2xmloutdata/bhyvexml2xmlout-serial-grub.xml | 1 + tests/bhyvexml2xmloutdata/bhyvexml2xmlout-serial.xml | 1 + tests/bhyvexml2xmltest.c | 3 ++- 27 files changed, 38 insertions(+), 5 deletions(-) diff --git a/src/bhyve/bhyve_domain.c b/src/bhyve/bhyve_domain.c index e2a20ce63..b4dc26767 100644 --- a/src/bhyve/bhyve_domain.c +++ b/src/bhyve/bhyve_domain.c @@ -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, diff --git a/src/bhyve/bhyve_domain.h b/src/bhyve/bhyve_domain.h index 0a6039216..bbc8ecd8c 100644 --- a/src/bhyve/bhyve_domain.h +++ b/src/bhyve/bhyve_domain.h @@ -37,6 +37,8 @@ struct _bhyveDomainObjPrivate { bhyveMonitorPtr mon; }; +virDomainXMLOptionPtr virBhyveDriverCreateXMLConf(bhyveConnPtr); + extern virDomainXMLPrivateDataCallbacks virBhyveDriverPrivateDataCallbacks; extern virDomainDefParserConfig virBhyveDriverDomainDefParserConfig; diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c index 17f85245d..504761f74 100644 --- a/src/bhyve/bhyve_driver.c +++ b/src/bhyve/bhyve_driver.c @@ -1239,9 +1239,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())) diff --git a/tests/bhyvexml2argvtest.c b/tests/bhyvexml2argvtest.c index 22a902c53..a615c8ca1 100644 --- a/tests/bhyvexml2argvtest.c +++ b/tests/bhyvexml2argvtest.c @@ -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) \ diff --git a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-acpiapic.xml b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-acpiapic.xml index b4720ecaf..ef57e0be6 100644 --- a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-acpiapic.xml +++ b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-acpiapic.xml @@ -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'/> diff --git a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-base.xml b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-base.xml index cd4e4f80d..0ff1a3c6b 100644 --- a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-base.xml +++ b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-base.xml @@ -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'/> diff --git a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-bhyveload-bootorder.xml b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-bhyveload-bootorder.xml index ab01cb5ab..6c092bb8d 100644 --- a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-bhyveload-bootorder.xml +++ b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-bhyveload-bootorder.xml @@ -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'/> diff --git a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-bhyveload-bootorder1.xml b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-bhyveload-bootorder1.xml index df69c4e87..f9e55d6e3 100644 --- a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-bhyveload-bootorder1.xml +++ b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-bhyveload-bootorder1.xml @@ -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'/> diff --git a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-bhyveload-bootorder2.xml b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-bhyveload-bootorder2.xml index 89131dc85..f75471f84 100644 --- a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-bhyveload-bootorder2.xml +++ b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-bhyveload-bootorder2.xml @@ -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'/> diff --git a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-bhyveload-bootorder3.xml b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-bhyveload-bootorder3.xml index 96f9dc4dd..8b9aeea18 100644 --- a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-bhyveload-bootorder3.xml +++ b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-bhyveload-bootorder3.xml @@ -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'/> diff --git a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-bhyveload-bootorder4.xml b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-bhyveload-bootorder4.xml index 1dd180bc0..a688d8a76 100644 --- a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-bhyveload-bootorder4.xml +++ b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-bhyveload-bootorder4.xml @@ -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'/> diff --git a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-bhyveload-explicitargs.xml b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-bhyveload-explicitargs.xml index d7743a640..bb7193037 100644 --- a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-bhyveload-explicitargs.xml +++ b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-bhyveload-explicitargs.xml @@ -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'/> diff --git a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-console.xml b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-console.xml index bf926f96b..bf9d6ad8a 100644 --- a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-console.xml +++ b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-console.xml @@ -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'/> diff --git a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-custom-loader.xml b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-custom-loader.xml index 3e7f145ed..53fd6b54b 100644 --- a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-custom-loader.xml +++ b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-custom-loader.xml @@ -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'/> diff --git a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-disk-cdrom-grub.xml b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-disk-cdrom-grub.xml index 285842c01..acdc4badb 100644 --- a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-disk-cdrom-grub.xml +++ b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-disk-cdrom-grub.xml @@ -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'/> diff --git a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-disk-cdrom.xml b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-disk-cdrom.xml index 02517e4fd..23f3f6f47 100644 --- a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-disk-cdrom.xml +++ b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-disk-cdrom.xml @@ -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'/> diff --git a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-disk-virtio.xml b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-disk-virtio.xml index 065ae813a..d7abb5abc 100644 --- a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-disk-virtio.xml +++ b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-disk-virtio.xml @@ -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'/> diff --git a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-grub-bootorder.xml b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-grub-bootorder.xml index 939f7ba58..f36daae10 100644 --- a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-grub-bootorder.xml +++ b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-grub-bootorder.xml @@ -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'/> diff --git a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-grub-bootorder2.xml b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-grub-bootorder2.xml index f774411e9..825ccd78f 100644 --- a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-grub-bootorder2.xml +++ b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-grub-bootorder2.xml @@ -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'/> diff --git a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-grub-defaults.xml b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-grub-defaults.xml index 758986b3f..b7f0a4886 100644 --- a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-grub-defaults.xml +++ b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-grub-defaults.xml @@ -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'/> diff --git a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-localtime.xml b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-localtime.xml index 7e08ff9de..95b01db2f 100644 --- a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-localtime.xml +++ b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-localtime.xml @@ -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'/> diff --git a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-macaddr.xml b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-macaddr.xml index 4e4e672fc..842194caa 100644 --- a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-macaddr.xml +++ b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-macaddr.xml @@ -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'/> diff --git a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-metadata.xml b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-metadata.xml index 77e18d48c..b44b6bd9e 100644 --- a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-metadata.xml +++ b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-metadata.xml @@ -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'/> diff --git a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-serial-grub-nocons.xml b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-serial-grub-nocons.xml index a379f1274..f4ace3979 100644 --- a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-serial-grub-nocons.xml +++ b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-serial-grub-nocons.xml @@ -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'/> diff --git a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-serial-grub.xml b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-serial-grub.xml index 2864089ae..f404ee7e3 100644 --- a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-serial-grub.xml +++ b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-serial-grub.xml @@ -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'/> diff --git a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-serial.xml b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-serial.xml index 954c58aca..d713deaee 100644 --- a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-serial.xml +++ b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-serial.xml @@ -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'/> diff --git a/tests/bhyvexml2xmltest.c b/tests/bhyvexml2xmltest.c index e95cee4b8..641ddb33e 100644 --- a/tests/bhyvexml2xmltest.c +++ b/tests/bhyvexml2xmltest.c @@ -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) \ -- 2.11.0

On 01/05/2017 09:46 AM, Roman Bogorodskiy wrote:
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.
It took a minute, but yeah I see why all the test results had to be changed (in a good direction, thankfully). ACK.

As bhyve for a long time didn't have a notion of the explicit SATA controller and created a controller for each drive, the bhyve driver in libvirt acted in a similar way and didn't care about the SATA controllers and assigned PCI addresses to drives directly, as the generated command will look like this anyway: 2:0,ahci-hd,somedisk.img This no longer makes sense because: 1. After commit c07d1c1c4f it's not possible to assign PCI addresses to disks 2. Bhyve now supports multiple disk drives for a controller, so it's going away from 1:1 controller:disk mapping, so the controller object starts to make more sense now So, this patch does the following: - Assign PCI address to SATA controllers (previously we didn't do this) - Assign disk addresses instead of PCI addresses for disks. Now, when building a bhyve command, we take PCI address not from the disk itself but from its controller - Assign addresses at XML parsing time using the assignAddressesCallback. This is done mainly for being able to verify address allocation via xml2xml tests - Adjust existing bhyvexml2{xml,argv} tests to chase the new address allocation This patch is largely based on work of Fabian Freyer. --- po/POTFILES.in | 1 + src/bhyve/bhyve_command.c | 143 ++++++++++++++++----- src/bhyve/bhyve_device.c | 33 ++--- src/bhyve/bhyve_domain.c | 60 ++++++++- .../bhyvexml2argvdata/bhyvexml2argv-acpiapic.args | 4 +- tests/bhyvexml2argvdata/bhyvexml2argv-base.args | 4 +- .../bhyvexml2argv-bhyveload-bootorder.args | 5 +- .../bhyvexml2argv-bhyveload-bootorder1.args | 5 +- .../bhyvexml2argv-bhyveload-bootorder3.args | 5 +- .../bhyvexml2argv-bhyveload-explicitargs.args | 4 +- tests/bhyvexml2argvdata/bhyvexml2argv-console.args | 2 +- .../bhyvexml2argv-custom-loader.args | 4 +- .../bhyvexml2argv-disk-cdrom-grub.args | 4 +- .../bhyvexml2argv-disk-cdrom.args | 4 +- .../bhyvexml2argv-grub-bootorder.args | 6 +- .../bhyvexml2argv-grub-bootorder2.args | 6 +- .../bhyvexml2argv-grub-defaults.args | 4 +- .../bhyvexml2argvdata/bhyvexml2argv-localtime.args | 4 +- tests/bhyvexml2argvdata/bhyvexml2argv-macaddr.args | 4 +- .../bhyvexml2argv-serial-grub-nocons.args | 2 +- .../bhyvexml2argv-serial-grub.args | 2 +- tests/bhyvexml2argvdata/bhyvexml2argv-serial.args | 2 +- tests/bhyvexml2argvtest.c | 2 +- .../bhyvexml2xmlout-acpiapic.xml | 4 +- tests/bhyvexml2xmloutdata/bhyvexml2xmlout-base.xml | 4 +- .../bhyvexml2xmlout-bhyveload-bootorder.xml | 4 +- .../bhyvexml2xmlout-bhyveload-bootorder1.xml | 4 +- .../bhyvexml2xmlout-bhyveload-bootorder2.xml | 4 +- .../bhyvexml2xmlout-bhyveload-bootorder3.xml | 4 +- .../bhyvexml2xmlout-bhyveload-bootorder4.xml | 4 +- .../bhyvexml2xmlout-bhyveload-explicitargs.xml | 4 +- .../bhyvexml2xmlout-console.xml | 4 +- .../bhyvexml2xmlout-custom-loader.xml | 4 +- .../bhyvexml2xmlout-disk-cdrom-grub.xml | 4 +- .../bhyvexml2xmlout-disk-cdrom.xml | 4 +- .../bhyvexml2xmlout-grub-bootorder.xml | 4 +- .../bhyvexml2xmlout-grub-bootorder2.xml | 4 +- .../bhyvexml2xmlout-grub-defaults.xml | 4 +- .../bhyvexml2xmlout-localtime.xml | 4 +- .../bhyvexml2xmlout-macaddr.xml | 4 +- .../bhyvexml2xmlout-metadata.xml | 5 +- .../bhyvexml2xmlout-serial-grub-nocons.xml | 4 +- .../bhyvexml2xmlout-serial-grub.xml | 4 +- .../bhyvexml2xmloutdata/bhyvexml2xmlout-serial.xml | 4 +- tests/bhyvexml2xmltest.c | 2 + 45 files changed, 279 insertions(+), 118 deletions(-) diff --git a/po/POTFILES.in b/po/POTFILES.in index e66bb7a3a..632aa7736 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -14,6 +14,7 @@ src/access/viraccessdriverpolkit.c src/access/viraccessmanager.c src/bhyve/bhyve_command.c src/bhyve/bhyve_device.c +src/bhyve/bhyve_domain.c src/bhyve/bhyve_driver.c src/bhyve/bhyve_monitor.c src/bhyve/bhyve_parse_command.c diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c index 8a29977ff..a2fd40378 100644 --- a/src/bhyve/bhyve_command.c +++ b/src/bhyve/bhyve_command.c @@ -148,40 +148,97 @@ bhyveBuildConsoleArgStr(const virDomainDef *def, virCommandPtr cmd) } static int -bhyveBuildDiskArgStr(const virDomainDef *def ATTRIBUTE_UNUSED, - virDomainDiskDefPtr disk, - virCommandPtr cmd) +bhyveBuildAHCIControllerArgStr(const virDomainDef *def, + virDomainControllerDefPtr controller, + virConnectPtr conn, + virCommandPtr cmd) { - const char *bus_type; + virBuffer buf = VIR_BUFFER_INITIALIZER; + virBuffer device = VIR_BUFFER_INITIALIZER; const char *disk_source; + size_t i; + int ret = -1; + + for (i = 0; i < def->ndisks; i++) { + virDomainDiskDefPtr disk = def->disks[i]; + if (disk->bus != VIR_DOMAIN_DISK_BUS_SATA) + continue; + + if (disk->info.addr.drive.controller != controller->idx) + continue; + + VIR_DEBUG("disk %zu controller %d", i, controller->idx); + + if ((virDomainDiskGetType(disk) != VIR_STORAGE_TYPE_FILE) && + (virDomainDiskGetType(disk) != VIR_STORAGE_TYPE_VOLUME)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("unsupported disk type")); + goto error; + } + + if (virStorageTranslateDiskSourcePool(conn, disk) < 0) + goto error; + + disk_source = virDomainDiskGetSource(disk); + + if ((disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM) && + (disk_source == NULL)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("cdrom device without source path " + "not supported")); + goto error; + } - switch (disk->bus) { - case VIR_DOMAIN_DISK_BUS_SATA: switch (disk->device) { case VIR_DOMAIN_DISK_DEVICE_DISK: - bus_type = "ahci-hd"; + if ((bhyveDriverGetCaps(conn) & BHYVE_CAP_AHCI32SLOT) != 0) + virBufferAsprintf(&device, ",hd:%s", disk_source); + else + virBufferAsprintf(&device, "-hd,%s", disk_source); break; case VIR_DOMAIN_DISK_DEVICE_CDROM: - bus_type = "ahci-cd"; + if ((bhyveDriverGetCaps(conn) & BHYVE_CAP_AHCI32SLOT) != 0) + virBufferAsprintf(&device, ",cd:%s", disk_source); + else + virBufferAsprintf(&device, "-cd,%s", disk_source); break; default: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("unsupported disk device")); - return -1; - } - break; - case VIR_DOMAIN_DISK_BUS_VIRTIO: - if (disk->device == VIR_DOMAIN_DISK_DEVICE_DISK) { - bus_type = "virtio-blk"; - } else { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("unsupported disk device")); - return -1; + goto error; } - break; - default: + virBufferAddBuffer(&buf, &device); + virBufferFreeAndReset(&device); + } + + if (virBufferCheckError(&buf) <0) + goto error; + + virCommandAddArg(cmd, "-s"); + virCommandAddArgFormat(cmd, "%d:0,ahci%s", + controller->info.addr.pci.slot, + virBufferCurrentContent(&buf)); + + ret = 0; + error: + virBufferFreeAndReset(&buf); + return ret; +} + +static int +bhyveBuildVirtIODiskArgStr(const virDomainDef *def ATTRIBUTE_UNUSED, + virDomainDiskDefPtr disk, + virConnectPtr conn, + virCommandPtr cmd) +{ + const char *disk_source; + + if (virStorageTranslateDiskSourcePool(conn, disk) < 0) + return -1; + + if (disk->device != VIR_DOMAIN_DISK_DEVICE_DISK) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("unsupported disk bus type")); + _("unsupported disk device")); return -1; } @@ -194,17 +251,9 @@ bhyveBuildDiskArgStr(const virDomainDef *def ATTRIBUTE_UNUSED, disk_source = virDomainDiskGetSource(disk); - if ((disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM) && - (disk_source == NULL)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("cdrom device without source path " - "not supported")); - return -1; - } - virCommandAddArg(cmd, "-s"); - virCommandAddArgFormat(cmd, "%d:0,%s,%s", - disk->info.addr.pci.slot, bus_type, + virCommandAddArgFormat(cmd, "%d:0,virtio-blk,%s", + disk->info.addr.pci.slot, disk_source); return 0; @@ -278,6 +327,22 @@ virBhyveProcessBuildBhyveCmd(virConnectPtr conn, virCommandAddArgList(cmd, "-s", "0:0,hostbridge", NULL); /* Devices */ + for (i = 0; i < def->ncontrollers; i++) { + virDomainControllerDefPtr controller = def->controllers[i]; + switch (controller->type) { + case VIR_DOMAIN_CONTROLLER_TYPE_PCI: + if (controller->model != VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + "%s", _("unsupported PCI controller model: only PCI root supported")); + goto error; + } + break; + case VIR_DOMAIN_CONTROLLER_TYPE_SATA: + if (bhyveBuildAHCIControllerArgStr(def, controller, conn, cmd) < 0) + goto error; + break; + } + } for (i = 0; i < def->nnets; i++) { virDomainNetDefPtr net = def->nets[i]; if (bhyveBuildNetArgStr(def, net, cmd, dryRun) < 0) @@ -286,11 +351,19 @@ virBhyveProcessBuildBhyveCmd(virConnectPtr conn, for (i = 0; i < def->ndisks; i++) { virDomainDiskDefPtr disk = def->disks[i]; - if (virStorageTranslateDiskSourcePool(conn, disk) < 0) - goto error; - - if (bhyveBuildDiskArgStr(def, disk, cmd) < 0) + switch (disk->bus) { + case VIR_DOMAIN_DISK_BUS_SATA: + /* Handled by AHCI controller */ + break; + case VIR_DOMAIN_DISK_BUS_VIRTIO: + if (bhyveBuildVirtIODiskArgStr(def, disk, conn, cmd) < 0) + goto error; + break; + default: + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("unsupported disk device")); goto error; + } } if (bhyveBuildConsoleArgStr(def, cmd) < 0) goto error; diff --git a/src/bhyve/bhyve_device.c b/src/bhyve/bhyve_device.c index ca30e9f46..4c770516c 100644 --- a/src/bhyve/bhyve_device.c +++ b/src/bhyve/bhyve_device.c @@ -39,6 +39,9 @@ bhyveCollectPCIAddress(virDomainDefPtr def ATTRIBUTE_UNUSED, void *opaque) { int ret = -1; + if (info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE) + return 0; + virDomainPCIAddressSetPtr addrs = opaque; virPCIDeviceAddressPtr addr = &info->addr.pci; @@ -97,27 +100,9 @@ bhyveAssignDevicePCISlots(virDomainDefPtr def, if (virDomainPCIAddressReserveSlot(addrs, &lpc_addr, VIR_PCI_CONNECT_TYPE_PCI_DEVICE) < 0) goto error; - for (i = 0; i < def->nnets; i++) { - if (!virDeviceInfoPCIAddressWanted(&def->nets[i]->info)) - continue; - if (virDomainPCIAddressReserveNextSlot(addrs, - &def->nets[i]->info, - VIR_PCI_CONNECT_TYPE_PCI_DEVICE) < 0) - goto error; - } - - for (i = 0; i < def->ndisks; i++) { - if (def->disks[i]->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI && - !virPCIDeviceAddressIsEmpty(&def->disks[i]->info.addr.pci)) - continue; - if (virDomainPCIAddressReserveNextSlot(addrs, - &def->disks[i]->info, - VIR_PCI_CONNECT_TYPE_PCI_DEVICE) < 0) - goto error; - } - for (i = 0; i < def->ncontrollers; i++) { - if (def->controllers[i]->type == VIR_DOMAIN_CONTROLLER_TYPE_PCI) { + if ((def->controllers[i]->type == VIR_DOMAIN_CONTROLLER_TYPE_PCI) || + (def->controllers[i]->type == VIR_DOMAIN_CONTROLLER_TYPE_SATA)) { if (def->controllers[i]->model == VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT || !virDeviceInfoPCIAddressWanted(&def->controllers[i]->info)) continue; @@ -127,7 +112,15 @@ bhyveAssignDevicePCISlots(virDomainDefPtr def, VIR_PCI_CONNECT_TYPE_PCI_DEVICE) < 0) goto error; } + } + for (i = 0; i < def->nnets; i++) { + if (!virDeviceInfoPCIAddressWanted(&def->nets[i]->info)) + continue; + if (virDomainPCIAddressReserveNextSlot(addrs, + &def->nets[i]->info, + VIR_PCI_CONNECT_TYPE_PCI_DEVICE) < 0) + goto error; } return 0; diff --git a/src/bhyve/bhyve_domain.c b/src/bhyve/bhyve_domain.c index b4dc26767..76b4fac2c 100644 --- a/src/bhyve/bhyve_domain.c +++ b/src/bhyve/bhyve_domain.c @@ -24,6 +24,7 @@ #include "bhyve_device.h" #include "bhyve_domain.h" +#include "bhyve_capabilities.h" #include "viralloc.h" #include "virlog.h" @@ -73,13 +74,67 @@ bhyveDomainDefPostParse(virDomainDefPtr def, } static int -bhyveDomainDeviceDefPostParse(virDomainDeviceDefPtr dev ATTRIBUTE_UNUSED, - const virDomainDef *def ATTRIBUTE_UNUSED, +bhyveDomainDiskDefAssignAddress(bhyveConnPtr driver, + virDomainDiskDefPtr def, + const virDomainDef *vmdef ATTRIBUTE_UNUSED) +{ + int idx = virDiskNameToIndex(def->dst); + + if (idx < 0) { + virReportError(VIR_ERR_XML_ERROR, + _("Unknown disk name '%s' and no address specified"), + def->dst); + return -1; + } + + switch (def->bus) { + case VIR_DOMAIN_DISK_BUS_SATA: + def->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE; + + if ((driver->bhyvecaps & BHYVE_CAP_AHCI32SLOT) != 0) { + def->info.addr.drive.controller = idx / 32; + def->info.addr.drive.unit = idx % 32; + } else { + def->info.addr.drive.controller = idx; + def->info.addr.drive.unit = 0; + } + + def->info.addr.drive.bus = 0; + break; + } + return 0; +} + +static int +bhyveDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, + const virDomainDef *def, + virCapsPtr caps ATTRIBUTE_UNUSED, + unsigned int parseFlags ATTRIBUTE_UNUSED, + void *opaque, + void *parseOpaque ATTRIBUTE_UNUSED) +{ + bhyveConnPtr driver = opaque; + + if (dev->type == VIR_DOMAIN_DEVICE_DISK) { + virDomainDiskDefPtr disk = dev->data.disk; + + if (disk->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE && + bhyveDomainDiskDefAssignAddress(driver, disk, def) < 0) + return -1; + } + return 0; +} + +static int +bhyveDomainDefAssignAddresses(virDomainDef *def, virCapsPtr caps ATTRIBUTE_UNUSED, unsigned int parseFlags ATTRIBUTE_UNUSED, void *opaque ATTRIBUTE_UNUSED, void *parseOpaque ATTRIBUTE_UNUSED) { + if (bhyveDomainAssignAddresses(def, NULL) < 0) + return -1; + return 0; } @@ -95,4 +150,5 @@ virBhyveDriverCreateXMLConf(bhyveConnPtr driver) virDomainDefParserConfig virBhyveDriverDomainDefParserConfig = { .devicesPostParseCallback = bhyveDomainDeviceDefPostParse, .domainPostParseCallback = bhyveDomainDefPostParse, + .assignAddressesCallback = bhyveDomainDefAssignAddresses, }; diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-acpiapic.args b/tests/bhyvexml2argvdata/bhyvexml2argv-acpiapic.args index 930166f07..e71ceec84 100644 --- a/tests/bhyvexml2argvdata/bhyvexml2argv-acpiapic.args +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-acpiapic.args @@ -7,5 +7,5 @@ -H \ -P \ -s 0:0,hostbridge \ --s 3:0,virtio-net,faketapdev,mac=52:54:00:81:c4:b1 \ --s 2:0,ahci-hd,/tmp/freebsd.img bhyve +-s 2:0,ahci,hd:/tmp/freebsd.img \ +-s 3:0,virtio-net,faketapdev,mac=52:54:00:81:c4:b1 bhyve diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-base.args b/tests/bhyvexml2argvdata/bhyvexml2argv-base.args index 76d597cc6..547485ba5 100644 --- a/tests/bhyvexml2argvdata/bhyvexml2argv-base.args +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-base.args @@ -5,5 +5,5 @@ -H \ -P \ -s 0:0,hostbridge \ --s 3:0,virtio-net,faketapdev,mac=52:54:00:b9:94:02 \ --s 2:0,ahci-hd,/tmp/freebsd.img bhyve +-s 2:0,ahci,hd:/tmp/freebsd.img \ +-s 3:0,virtio-net,faketapdev,mac=52:54:00:b9:94:02 bhyve diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-bootorder.args b/tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-bootorder.args index a303ee3c5..4d7c7c92a 100644 --- a/tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-bootorder.args +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-bootorder.args @@ -5,6 +5,5 @@ -H \ -P \ -s 0:0,hostbridge \ --s 3:0,virtio-net,faketapdev,mac=52:54:00:8d:10:e1 \ --s 2:0,ahci-hd,/tmp/freebsd.img \ --s 4:0,ahci-cd,/tmp/cdrom.iso bhyve +-s 2:0,ahci,hd:/tmp/freebsd.img,cd:/tmp/cdrom.iso \ +-s 3:0,virtio-net,faketapdev,mac=52:54:00:8d:10:e1 bhyve diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-bootorder1.args b/tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-bootorder1.args index 04601319b..8ec9799cc 100644 --- a/tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-bootorder1.args +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-bootorder1.args @@ -5,6 +5,5 @@ -H \ -P \ -s 0:0,hostbridge \ --s 3:0,virtio-net,faketapdev,mac=52:54:00:92:68:0e \ --s 2:0,ahci-hd,/tmp/freebsd.img \ --s 4:0,ahci-cd,/tmp/cdrom.iso bhyve +-s 2:0,ahci,hd:/tmp/freebsd.img,cd:/tmp/cdrom.iso \ +-s 3:0,virtio-net,faketapdev,mac=52:54:00:92:68:0e bhyve diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-bootorder3.args b/tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-bootorder3.args index 79631c3a6..f1c0bf398 100644 --- a/tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-bootorder3.args +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-bootorder3.args @@ -5,6 +5,5 @@ -H \ -P \ -s 0:0,hostbridge \ --s 3:0,virtio-net,faketapdev,mac=52:54:00:7a:f5:a4 \ --s 2:0,ahci-hd,/tmp/freebsd.img \ --s 4:0,ahci-cd,/tmp/cdrom.iso bhyve +-s 2:0,ahci,hd:/tmp/freebsd.img,cd:/tmp/cdrom.iso \ +-s 3:0,virtio-net,faketapdev,mac=52:54:00:7a:f5:a4 bhyve diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-explicitargs.args b/tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-explicitargs.args index e80ff026a..17a1c8380 100644 --- a/tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-explicitargs.args +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-bhyveload-explicitargs.args @@ -5,5 +5,5 @@ -H \ -P \ -s 0:0,hostbridge \ --s 3:0,virtio-net,faketapdev,mac=52:54:00:11:bd:26 \ --s 2:0,ahci-hd,/tmp/freebsd.img bhyve +-s 2:0,ahci,hd:/tmp/freebsd.img \ +-s 3:0,virtio-net,faketapdev,mac=52:54:00:11:bd:26 bhyve diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-console.args b/tests/bhyvexml2argvdata/bhyvexml2argv-console.args index bd2892c47..6ab91ae7e 100644 --- a/tests/bhyvexml2argvdata/bhyvexml2argv-console.args +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-console.args @@ -5,7 +5,7 @@ -H \ -P \ -s 0:0,hostbridge \ +-s 2:0,ahci,hd:/tmp/freebsd.img \ -s 3:0,virtio-net,faketapdev,mac=52:54:00:b1:42:eb \ --s 2:0,ahci-hd,/tmp/freebsd.img \ -s 1,lpc \ -l com1,/dev/nmdm0A bhyve diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-custom-loader.args b/tests/bhyvexml2argvdata/bhyvexml2argv-custom-loader.args index 7a0eeb2fc..f6bfc7837 100644 --- a/tests/bhyvexml2argvdata/bhyvexml2argv-custom-loader.args +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-custom-loader.args @@ -5,5 +5,5 @@ -H \ -P \ -s 0:0,hostbridge \ --s 3:0,virtio-net,faketapdev,mac=52:54:00:35:99:c2 \ --s 2:0,ahci-hd,/tmp/freebsd.img bhyve +-s 2:0,ahci,hd:/tmp/freebsd.img \ +-s 3:0,virtio-net,faketapdev,mac=52:54:00:35:99:c2 bhyve diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-disk-cdrom-grub.args b/tests/bhyvexml2argvdata/bhyvexml2argv-disk-cdrom-grub.args index 907751c6c..72f1d3538 100644 --- a/tests/bhyvexml2argvdata/bhyvexml2argv-disk-cdrom-grub.args +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-disk-cdrom-grub.args @@ -5,5 +5,5 @@ -H \ -P \ -s 0:0,hostbridge \ --s 3:0,virtio-net,faketapdev,mac=52:54:00:6f:6a:53 \ --s 2:0,ahci-cd,/tmp/cdrom.iso bhyve +-s 2:0,ahci,cd:/tmp/cdrom.iso \ +-s 3:0,virtio-net,faketapdev,mac=52:54:00:6f:6a:53 bhyve diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-disk-cdrom.args b/tests/bhyvexml2argvdata/bhyvexml2argv-disk-cdrom.args index 180650555..3e61b8fc8 100644 --- a/tests/bhyvexml2argvdata/bhyvexml2argv-disk-cdrom.args +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-disk-cdrom.args @@ -5,5 +5,5 @@ -H \ -P \ -s 0:0,hostbridge \ --s 3:0,virtio-net,faketapdev,mac=52:54:00:e3:ec:9b \ --s 2:0,ahci-cd,/tmp/cdrom.iso bhyve +-s 2:0,ahci,cd:/tmp/cdrom.iso \ +-s 3:0,virtio-net,faketapdev,mac=52:54:00:e3:ec:9b bhyve diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-grub-bootorder.args b/tests/bhyvexml2argvdata/bhyvexml2argv-grub-bootorder.args index 1b38be1ab..e64e67b39 100644 --- a/tests/bhyvexml2argvdata/bhyvexml2argv-grub-bootorder.args +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-grub-bootorder.args @@ -5,7 +5,5 @@ -H \ -P \ -s 0:0,hostbridge \ --s 3:0,virtio-net,faketapdev,mac=52:54:00:f4:6c:be \ --s 2:0,ahci-hd,/tmp/freebsd1.img \ --s 4:0,ahci-hd,/tmp/freebsd2.img \ --s 6:0,ahci-hd,/tmp/freebsd3.img bhyve +-s 2:0,ahci,hd:/tmp/freebsd1.img,hd:/tmp/freebsd2.img,hd:/tmp/freebsd3.img \ +-s 3:0,virtio-net,faketapdev,mac=52:54:00:f4:6c:be bhyve diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-grub-bootorder2.args b/tests/bhyvexml2argvdata/bhyvexml2argv-grub-bootorder2.args index ae510d50d..872a69df3 100644 --- a/tests/bhyvexml2argvdata/bhyvexml2argv-grub-bootorder2.args +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-grub-bootorder2.args @@ -5,7 +5,5 @@ -H \ -P \ -s 0:0,hostbridge \ --s 3:0,virtio-net,faketapdev,mac=52:54:00:0e:d2:6f \ --s 2:0,ahci-hd,/tmp/freebsd1.img \ --s 4:0,ahci-hd,/tmp/freebsd2.img \ --s 6:0,ahci-hd,/tmp/freebsd3.img bhyve +-s 2:0,ahci,hd:/tmp/freebsd1.img,hd:/tmp/freebsd2.img,hd:/tmp/freebsd3.img \ +-s 3:0,virtio-net,faketapdev,mac=52:54:00:0e:d2:6f bhyve diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-grub-defaults.args b/tests/bhyvexml2argvdata/bhyvexml2argv-grub-defaults.args index 9457ce955..3ba5c1160 100644 --- a/tests/bhyvexml2argvdata/bhyvexml2argv-grub-defaults.args +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-grub-defaults.args @@ -5,5 +5,5 @@ -H \ -P \ -s 0:0,hostbridge \ --s 3:0,virtio-net,faketapdev,mac=52:54:00:ee:f5:79 \ --s 2:0,ahci-hd,/tmp/freebsd.img bhyve +-s 2:0,ahci,hd:/tmp/freebsd.img \ +-s 3:0,virtio-net,faketapdev,mac=52:54:00:ee:f5:79 bhyve diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-localtime.args b/tests/bhyvexml2argvdata/bhyvexml2argv-localtime.args index 3f62aa7fb..307d888c1 100644 --- a/tests/bhyvexml2argvdata/bhyvexml2argv-localtime.args +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-localtime.args @@ -4,5 +4,5 @@ -H \ -P \ -s 0:0,hostbridge \ --s 3:0,virtio-net,faketapdev,mac=52:54:00:82:ca:a3 \ --s 2:0,ahci-hd,/tmp/freebsd.img bhyve +-s 2:0,ahci,hd:/tmp/freebsd.img \ +-s 3:0,virtio-net,faketapdev,mac=52:54:00:82:ca:a3 bhyve diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-macaddr.args b/tests/bhyvexml2argvdata/bhyvexml2argv-macaddr.args index 677a466ba..5e13a9742 100644 --- a/tests/bhyvexml2argvdata/bhyvexml2argv-macaddr.args +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-macaddr.args @@ -5,5 +5,5 @@ -H \ -P \ -s 0:0,hostbridge \ --s 3:0,virtio-net,faketapdev,mac=52:54:00:22:ee:11 \ --s 2:0,ahci-hd,/tmp/freebsd.img bhyve +-s 2:0,ahci,hd:/tmp/freebsd.img \ +-s 3:0,virtio-net,faketapdev,mac=52:54:00:22:ee:11 bhyve diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub-nocons.args b/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub-nocons.args index 4811d491b..ff69ed3a7 100644 --- a/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub-nocons.args +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub-nocons.args @@ -5,7 +5,7 @@ -H \ -P \ -s 0:0,hostbridge \ +-s 2:0,ahci,hd:/tmp/freebsd.img \ -s 3:0,virtio-net,faketapdev,mac=52:54:00:a7:cd:5b \ --s 2:0,ahci-hd,/tmp/freebsd.img \ -s 1,lpc \ -l com1,/dev/nmdm0A bhyve diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub.args b/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub.args index efdbd63a5..313724dc9 100644 --- a/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub.args +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub.args @@ -5,7 +5,7 @@ -H \ -P \ -s 0:0,hostbridge \ +-s 2:0,ahci,hd:/tmp/freebsd.img \ -s 3:0,virtio-net,faketapdev,mac=52:54:00:f0:72:11 \ --s 2:0,ahci-hd,/tmp/freebsd.img \ -s 1,lpc \ -l com1,/dev/nmdm0A bhyve diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-serial.args b/tests/bhyvexml2argvdata/bhyvexml2argv-serial.args index ccce58263..059e45707 100644 --- a/tests/bhyvexml2argvdata/bhyvexml2argv-serial.args +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-serial.args @@ -5,7 +5,7 @@ -H \ -P \ -s 0:0,hostbridge \ +-s 2:0,ahci,hd:/tmp/freebsd.img \ -s 3:0,virtio-net,faketapdev,mac=52:54:00:4f:f3:5b \ --s 2:0,ahci-hd,/tmp/freebsd.img \ -s 1,lpc \ -l com1,/dev/nmdm0A bhyve diff --git a/tests/bhyvexml2argvtest.c b/tests/bhyvexml2argvtest.c index a615c8ca1..6d0a9e1f8 100644 --- a/tests/bhyvexml2argvtest.c +++ b/tests/bhyvexml2argvtest.c @@ -155,7 +155,7 @@ mymain(void) DO_TEST_FULL(name, FLAG_EXPECT_PARSE_ERROR) driver.grubcaps = BHYVE_GRUB_CAP_CONSDEV; - driver.bhyvecaps = BHYVE_CAP_RTC_UTC; + driver.bhyvecaps = BHYVE_CAP_RTC_UTC | BHYVE_CAP_AHCI32SLOT; DO_TEST("base"); DO_TEST("acpiapic"); diff --git a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-acpiapic.xml b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-acpiapic.xml index ef57e0be6..0a9b284ff 100644 --- a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-acpiapic.xml +++ b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-acpiapic.xml @@ -24,7 +24,9 @@ <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'/> + <controller type='sata' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> + </controller> <interface type='bridge'> <mac address='52:54:00:81:c4:b1'/> <source bridge='virbr0'/> diff --git a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-base.xml b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-base.xml index 0ff1a3c6b..56ff3bd14 100644 --- a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-base.xml +++ b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-base.xml @@ -20,7 +20,9 @@ <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'/> + <controller type='sata' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> + </controller> <interface type='bridge'> <mac address='52:54:00:b9:94:02'/> <source bridge='virbr0'/> diff --git a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-bhyveload-bootorder.xml b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-bhyveload-bootorder.xml index 6c092bb8d..c4705d9a8 100644 --- a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-bhyveload-bootorder.xml +++ b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-bhyveload-bootorder.xml @@ -27,7 +27,9 @@ <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'/> + <controller type='sata' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> + </controller> <interface type='bridge'> <mac address='52:54:00:8d:10:e1'/> <source bridge='virbr0'/> diff --git a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-bhyveload-bootorder1.xml b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-bhyveload-bootorder1.xml index f9e55d6e3..ebc781e74 100644 --- a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-bhyveload-bootorder1.xml +++ b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-bhyveload-bootorder1.xml @@ -27,7 +27,9 @@ <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'/> + <controller type='sata' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> + </controller> <interface type='bridge'> <mac address='52:54:00:92:68:0e'/> <source bridge='virbr0'/> diff --git a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-bhyveload-bootorder2.xml b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-bhyveload-bootorder2.xml index f75471f84..389355f91 100644 --- a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-bhyveload-bootorder2.xml +++ b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-bhyveload-bootorder2.xml @@ -20,7 +20,9 @@ <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'/> + <controller type='sata' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> + </controller> <interface type='bridge'> <mac address='52:54:00:1e:63:25'/> <source bridge='virbr0'/> diff --git a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-bhyveload-bootorder3.xml b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-bhyveload-bootorder3.xml index 8b9aeea18..10ba21793 100644 --- a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-bhyveload-bootorder3.xml +++ b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-bhyveload-bootorder3.xml @@ -27,7 +27,9 @@ <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'/> + <controller type='sata' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> + </controller> <interface type='bridge'> <mac address='52:54:00:7a:f5:a4'/> <source bridge='virbr0'/> diff --git a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-bhyveload-bootorder4.xml b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-bhyveload-bootorder4.xml index a688d8a76..2215c7327 100644 --- a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-bhyveload-bootorder4.xml +++ b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-bhyveload-bootorder4.xml @@ -28,7 +28,9 @@ <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'/> + <controller type='sata' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> + </controller> <interface type='bridge'> <mac address='52:54:00:fe:97:82'/> <source bridge='virbr0'/> diff --git a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-bhyveload-explicitargs.xml b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-bhyveload-explicitargs.xml index bb7193037..6c6ed114d 100644 --- a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-bhyveload-explicitargs.xml +++ b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-bhyveload-explicitargs.xml @@ -20,7 +20,9 @@ <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'/> + <controller type='sata' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> + </controller> <interface type='bridge'> <mac address='52:54:00:11:bd:26'/> <source bridge='virbr0'/> diff --git a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-console.xml b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-console.xml index bf9d6ad8a..78d4d3001 100644 --- a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-console.xml +++ b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-console.xml @@ -20,7 +20,9 @@ <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'/> + <controller type='sata' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> + </controller> <interface type='bridge'> <mac address='52:54:00:b1:42:eb'/> <source bridge='virbr0'/> diff --git a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-custom-loader.xml b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-custom-loader.xml index 53fd6b54b..8bb0d53b7 100644 --- a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-custom-loader.xml +++ b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-custom-loader.xml @@ -21,7 +21,9 @@ <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'/> + <controller type='sata' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> + </controller> <interface type='bridge'> <mac address='52:54:00:35:99:c2'/> <source bridge='virbr0'/> diff --git a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-disk-cdrom-grub.xml b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-disk-cdrom-grub.xml index acdc4badb..b624f3d97 100644 --- a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-disk-cdrom-grub.xml +++ b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-disk-cdrom-grub.xml @@ -21,7 +21,9 @@ <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'/> + <controller type='sata' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> + </controller> <interface type='bridge'> <mac address='52:54:00:6f:6a:53'/> <source bridge='virbr0'/> diff --git a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-disk-cdrom.xml b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-disk-cdrom.xml index 23f3f6f47..ef3cd9fff 100644 --- a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-disk-cdrom.xml +++ b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-disk-cdrom.xml @@ -21,7 +21,9 @@ <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'/> + <controller type='sata' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> + </controller> <interface type='bridge'> <mac address='52:54:00:e3:ec:9b'/> <source bridge='virbr0'/> diff --git a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-grub-bootorder.xml b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-grub-bootorder.xml index f36daae10..da55c0aae 100644 --- a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-grub-bootorder.xml +++ b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-grub-bootorder.xml @@ -33,7 +33,9 @@ <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'/> + <controller type='sata' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> + </controller> <interface type='bridge'> <mac address='52:54:00:f4:6c:be'/> <source bridge='virbr0'/> diff --git a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-grub-bootorder2.xml b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-grub-bootorder2.xml index 825ccd78f..3974d5bc5 100644 --- a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-grub-bootorder2.xml +++ b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-grub-bootorder2.xml @@ -35,7 +35,9 @@ <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'/> + <controller type='sata' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> + </controller> <interface type='bridge'> <mac address='52:54:00:0e:d2:6f'/> <source bridge='virbr0'/> diff --git a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-grub-defaults.xml b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-grub-defaults.xml index b7f0a4886..270d41c83 100644 --- a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-grub-defaults.xml +++ b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-grub-defaults.xml @@ -20,7 +20,9 @@ <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'/> + <controller type='sata' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> + </controller> <interface type='bridge'> <mac address='52:54:00:ee:f5:79'/> <source bridge='virbr0'/> diff --git a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-localtime.xml b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-localtime.xml index 95b01db2f..2d1b729e6 100644 --- a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-localtime.xml +++ b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-localtime.xml @@ -20,7 +20,9 @@ <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'/> + <controller type='sata' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> + </controller> <interface type='bridge'> <mac address='52:54:00:82:ca:a3'/> <source bridge='virbr0'/> diff --git a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-macaddr.xml b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-macaddr.xml index 842194caa..6710818ee 100644 --- a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-macaddr.xml +++ b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-macaddr.xml @@ -20,7 +20,9 @@ <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'/> + <controller type='sata' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> + </controller> <interface type='bridge'> <mac address='52:54:00:22:ee:11'/> <source bridge='virbr0'/> diff --git a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-metadata.xml b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-metadata.xml index b44b6bd9e..5c5109404 100644 --- a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-metadata.xml +++ b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-metadata.xml @@ -24,11 +24,14 @@ <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'/> + <controller type='sata' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> + </controller> <interface type='bridge'> <mac address='52:54:00:ad:55:51'/> <source bridge='virbr0'/> <model type='virtio'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> </interface> </devices> </domain> diff --git a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-serial-grub-nocons.xml b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-serial-grub-nocons.xml index f4ace3979..845cb09e9 100644 --- a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-serial-grub-nocons.xml +++ b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-serial-grub-nocons.xml @@ -20,7 +20,9 @@ <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'/> + <controller type='sata' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> + </controller> <interface type='bridge'> <mac address='52:54:00:a7:cd:5b'/> <source bridge='virbr0'/> diff --git a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-serial-grub.xml b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-serial-grub.xml index f404ee7e3..6c8fda32a 100644 --- a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-serial-grub.xml +++ b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-serial-grub.xml @@ -20,7 +20,9 @@ <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'/> + <controller type='sata' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> + </controller> <interface type='bridge'> <mac address='52:54:00:f0:72:11'/> <source bridge='virbr0'/> diff --git a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-serial.xml b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-serial.xml index d713deaee..eb50cc05a 100644 --- a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-serial.xml +++ b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-serial.xml @@ -20,7 +20,9 @@ <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'/> + <controller type='sata' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> + </controller> <interface type='bridge'> <mac address='52:54:00:4f:f3:5b'/> <source bridge='virbr0'/> diff --git a/tests/bhyvexml2xmltest.c b/tests/bhyvexml2xmltest.c index 641ddb33e..93ab3800c 100644 --- a/tests/bhyvexml2xmltest.c +++ b/tests/bhyvexml2xmltest.c @@ -64,6 +64,8 @@ mymain(void) # define DO_TEST_DIFFERENT(name) \ DO_TEST_FULL(name, true) + driver.bhyvecaps = BHYVE_CAP_AHCI32SLOT; + DO_TEST_DIFFERENT("acpiapic"); DO_TEST_DIFFERENT("base"); DO_TEST_DIFFERENT("bhyveload-bootorder"); -- 2.11.0

On 01/05/2017 09:46 AM, Roman Bogorodskiy wrote:
As bhyve for a long time didn't have a notion of the explicit SATA controller and created a controller for each drive, the bhyve driver in libvirt acted in a similar way and didn't care about the SATA controllers and assigned PCI addresses to drives directly, as the generated command will look like this anyway:
2:0,ahci-hd,somedisk.img
This no longer makes sense because:
1. After commit c07d1c1c4f it's not possible to assign PCI addresses to disks 2. Bhyve now supports multiple disk drives for a controller, so it's going away from 1:1 controller:disk mapping, so the controller object starts to make more sense now
So, this patch does the following:
- Assign PCI address to SATA controllers (previously we didn't do this) - Assign disk addresses instead of PCI addresses for disks. Now, when building a bhyve command, we take PCI address not from the disk itself but from its controller - Assign addresses at XML parsing time using the assignAddressesCallback. This is done mainly for being able to verify address allocation via xml2xml tests - Adjust existing bhyvexml2{xml,argv} tests to chase the new address allocation
This patch is largely based on work of Fabian Freyer. --- po/POTFILES.in | 1 + src/bhyve/bhyve_command.c | 143 ++++++++++++++++----- src/bhyve/bhyve_device.c | 33 ++--- src/bhyve/bhyve_domain.c | 60 ++++++++- .../bhyvexml2argvdata/bhyvexml2argv-acpiapic.args | 4 +- tests/bhyvexml2argvdata/bhyvexml2argv-base.args | 4 +- .../bhyvexml2argv-bhyveload-bootorder.args | 5 +- .../bhyvexml2argv-bhyveload-bootorder1.args | 5 +- .../bhyvexml2argv-bhyveload-bootorder3.args | 5 +- .../bhyvexml2argv-bhyveload-explicitargs.args | 4 +- tests/bhyvexml2argvdata/bhyvexml2argv-console.args | 2 +- .../bhyvexml2argv-custom-loader.args | 4 +- .../bhyvexml2argv-disk-cdrom-grub.args | 4 +- .../bhyvexml2argv-disk-cdrom.args | 4 +- .../bhyvexml2argv-grub-bootorder.args | 6 +- .../bhyvexml2argv-grub-bootorder2.args | 6 +- .../bhyvexml2argv-grub-defaults.args | 4 +- .../bhyvexml2argvdata/bhyvexml2argv-localtime.args | 4 +- tests/bhyvexml2argvdata/bhyvexml2argv-macaddr.args | 4 +- .../bhyvexml2argv-serial-grub-nocons.args | 2 +- .../bhyvexml2argv-serial-grub.args | 2 +- tests/bhyvexml2argvdata/bhyvexml2argv-serial.args | 2 +- tests/bhyvexml2argvtest.c | 2 +- .../bhyvexml2xmlout-acpiapic.xml | 4 +- tests/bhyvexml2xmloutdata/bhyvexml2xmlout-base.xml | 4 +- .../bhyvexml2xmlout-bhyveload-bootorder.xml | 4 +- .../bhyvexml2xmlout-bhyveload-bootorder1.xml | 4 +- .../bhyvexml2xmlout-bhyveload-bootorder2.xml | 4 +- .../bhyvexml2xmlout-bhyveload-bootorder3.xml | 4 +- .../bhyvexml2xmlout-bhyveload-bootorder4.xml | 4 +- .../bhyvexml2xmlout-bhyveload-explicitargs.xml | 4 +- .../bhyvexml2xmlout-console.xml | 4 +- .../bhyvexml2xmlout-custom-loader.xml | 4 +- .../bhyvexml2xmlout-disk-cdrom-grub.xml | 4 +- .../bhyvexml2xmlout-disk-cdrom.xml | 4 +- .../bhyvexml2xmlout-grub-bootorder.xml | 4 +- .../bhyvexml2xmlout-grub-bootorder2.xml | 4 +- .../bhyvexml2xmlout-grub-defaults.xml | 4 +- .../bhyvexml2xmlout-localtime.xml | 4 +- .../bhyvexml2xmlout-macaddr.xml | 4 +- .../bhyvexml2xmlout-metadata.xml | 5 +- .../bhyvexml2xmlout-serial-grub-nocons.xml | 4 +- .../bhyvexml2xmlout-serial-grub.xml | 4 +- .../bhyvexml2xmloutdata/bhyvexml2xmlout-serial.xml | 4 +- tests/bhyvexml2xmltest.c | 2 + 45 files changed, 279 insertions(+), 118 deletions(-)
diff --git a/po/POTFILES.in b/po/POTFILES.in index e66bb7a3a..632aa7736 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -14,6 +14,7 @@ src/access/viraccessdriverpolkit.c src/access/viraccessmanager.c src/bhyve/bhyve_command.c src/bhyve/bhyve_device.c +src/bhyve/bhyve_domain.c src/bhyve/bhyve_driver.c src/bhyve/bhyve_monitor.c src/bhyve/bhyve_parse_command.c diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c index 8a29977ff..a2fd40378 100644 --- a/src/bhyve/bhyve_command.c +++ b/src/bhyve/bhyve_command.c @@ -148,40 +148,97 @@ bhyveBuildConsoleArgStr(const virDomainDef *def, virCommandPtr cmd) }
static int -bhyveBuildDiskArgStr(const virDomainDef *def ATTRIBUTE_UNUSED, - virDomainDiskDefPtr disk, - virCommandPtr cmd) +bhyveBuildAHCIControllerArgStr(const virDomainDef *def, + virDomainControllerDefPtr controller, + virConnectPtr conn, + virCommandPtr cmd) { - const char *bus_type; + virBuffer buf = VIR_BUFFER_INITIALIZER; + virBuffer device = VIR_BUFFER_INITIALIZER; const char *disk_source; + size_t i; + int ret = -1; + + for (i = 0; i < def->ndisks; i++) { + virDomainDiskDefPtr disk = def->disks[i]; + if (disk->bus != VIR_DOMAIN_DISK_BUS_SATA) + continue; + + if (disk->info.addr.drive.controller != controller->idx) + continue;
Took a minute for me to see why you were doing this - so all the disks attached to a controller are put directly into the controller's commandline arg rather than them being separate args with a ref back to the controller.
+ + VIR_DEBUG("disk %zu controller %d", i, controller->idx); + + if ((virDomainDiskGetType(disk) != VIR_STORAGE_TYPE_FILE) && + (virDomainDiskGetType(disk) != VIR_STORAGE_TYPE_VOLUME)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("unsupported disk type")); + goto error; + } + + if (virStorageTranslateDiskSourcePool(conn, disk) < 0) + goto error; + + disk_source = virDomainDiskGetSource(disk); + + if ((disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM) && + (disk_source == NULL)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("cdrom device without source path " + "not supported")); + goto error; + }
- switch (disk->bus) { - case VIR_DOMAIN_DISK_BUS_SATA: switch (disk->device) { case VIR_DOMAIN_DISK_DEVICE_DISK: - bus_type = "ahci-hd"; + if ((bhyveDriverGetCaps(conn) & BHYVE_CAP_AHCI32SLOT) != 0)
The "!= 0" is superfluous.
+ virBufferAsprintf(&device, ",hd:%s", disk_source); + else + virBufferAsprintf(&device, "-hd,%s", disk_source); break; case VIR_DOMAIN_DISK_DEVICE_CDROM: - bus_type = "ahci-cd"; + if ((bhyveDriverGetCaps(conn) & BHYVE_CAP_AHCI32SLOT) != 0)
Same here.
+ virBufferAsprintf(&device, ",cd:%s", disk_source); + else + virBufferAsprintf(&device, "-cd,%s", disk_source);
It seems like there could be some consolidation of the multiple nearly-identical printf's here. Possibly not worth the trouble though.
break; default: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("unsupported disk device")); - return -1; - } - break; - case VIR_DOMAIN_DISK_BUS_VIRTIO: - if (disk->device == VIR_DOMAIN_DISK_DEVICE_DISK) { - bus_type = "virtio-blk"; - } else { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("unsupported disk device")); - return -1; + goto error; } - break; - default: + virBufferAddBuffer(&buf, &device); + virBufferFreeAndReset(&device); + } + + if (virBufferCheckError(&buf) <0) + goto error; + + virCommandAddArg(cmd, "-s"); + virCommandAddArgFormat(cmd, "%d:0,ahci%s", + controller->info.addr.pci.slot, + virBufferCurrentContent(&buf)); + + ret = 0; + error: + virBufferFreeAndReset(&buf); + return ret; +} + +static int +bhyveBuildVirtIODiskArgStr(const virDomainDef *def ATTRIBUTE_UNUSED, + virDomainDiskDefPtr disk, + virConnectPtr conn, + virCommandPtr cmd) +{ + const char *disk_source; + + if (virStorageTranslateDiskSourcePool(conn, disk) < 0) + return -1; + + if (disk->device != VIR_DOMAIN_DISK_DEVICE_DISK) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("unsupported disk bus type")); + _("unsupported disk device")); return -1; }
@@ -194,17 +251,9 @@ bhyveBuildDiskArgStr(const virDomainDef *def ATTRIBUTE_UNUSED,
disk_source = virDomainDiskGetSource(disk);
- if ((disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM) && - (disk_source == NULL)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("cdrom device without source path " - "not supported")); - return -1; - } - virCommandAddArg(cmd, "-s"); - virCommandAddArgFormat(cmd, "%d:0,%s,%s", - disk->info.addr.pci.slot, bus_type, + virCommandAddArgFormat(cmd, "%d:0,virtio-blk,%s", + disk->info.addr.pci.slot, disk_source);
return 0; @@ -278,6 +327,22 @@ virBhyveProcessBuildBhyveCmd(virConnectPtr conn,
virCommandAddArgList(cmd, "-s", "0:0,hostbridge", NULL); /* Devices */ + for (i = 0; i < def->ncontrollers; i++) { + virDomainControllerDefPtr controller = def->controllers[i]; + switch (controller->type) { + case VIR_DOMAIN_CONTROLLER_TYPE_PCI: + if (controller->model != VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + "%s", _("unsupported PCI controller model: only PCI root supported")); + goto error; + } + break; + case VIR_DOMAIN_CONTROLLER_TYPE_SATA: + if (bhyveBuildAHCIControllerArgStr(def, controller, conn, cmd) < 0) + goto error; + break; + } + } for (i = 0; i < def->nnets; i++) { virDomainNetDefPtr net = def->nets[i]; if (bhyveBuildNetArgStr(def, net, cmd, dryRun) < 0) @@ -286,11 +351,19 @@ virBhyveProcessBuildBhyveCmd(virConnectPtr conn, for (i = 0; i < def->ndisks; i++) { virDomainDiskDefPtr disk = def->disks[i];
- if (virStorageTranslateDiskSourcePool(conn, disk) < 0) - goto error; - - if (bhyveBuildDiskArgStr(def, disk, cmd) < 0) + switch (disk->bus) { + case VIR_DOMAIN_DISK_BUS_SATA: + /* Handled by AHCI controller */ + break;
This is a bit odd, but I see why you're doing it. Maybe you should put the full name of the function (bhyveBuildAHCIControllerArgStr) in the comment rather than just "AHCI controller". Aside from these minor nits, my only concern is that of compatibility when migrating forward and backward, but since I don't have a system with bhyve I can't test that, so I'll assume that you've done your due diligence in that regard. (Also, I'm assuming that you've successfully run make syntax-check in addition to make check). Based on those assumptions, ACK.

Laine Stump wrote:
On 01/05/2017 09:46 AM, Roman Bogorodskiy wrote:
As bhyve for a long time didn't have a notion of the explicit SATA controller and created a controller for each drive, the bhyve driver in libvirt acted in a similar way and didn't care about the SATA controllers and assigned PCI addresses to drives directly, as the generated command will look like this anyway:
2:0,ahci-hd,somedisk.img
This no longer makes sense because:
1. After commit c07d1c1c4f it's not possible to assign PCI addresses to disks 2. Bhyve now supports multiple disk drives for a controller, so it's going away from 1:1 controller:disk mapping, so the controller object starts to make more sense now
So, this patch does the following:
- Assign PCI address to SATA controllers (previously we didn't do this) - Assign disk addresses instead of PCI addresses for disks. Now, when building a bhyve command, we take PCI address not from the disk itself but from its controller - Assign addresses at XML parsing time using the assignAddressesCallback. This is done mainly for being able to verify address allocation via xml2xml tests - Adjust existing bhyvexml2{xml,argv} tests to chase the new address allocation
This patch is largely based on work of Fabian Freyer. --- po/POTFILES.in | 1 + src/bhyve/bhyve_command.c | 143 ++++++++++++++++----- src/bhyve/bhyve_device.c | 33 ++--- src/bhyve/bhyve_domain.c | 60 ++++++++- .../bhyvexml2argvdata/bhyvexml2argv-acpiapic.args | 4 +- tests/bhyvexml2argvdata/bhyvexml2argv-base.args | 4 +- .../bhyvexml2argv-bhyveload-bootorder.args | 5 +- .../bhyvexml2argv-bhyveload-bootorder1.args | 5 +- .../bhyvexml2argv-bhyveload-bootorder3.args | 5 +- .../bhyvexml2argv-bhyveload-explicitargs.args | 4 +- tests/bhyvexml2argvdata/bhyvexml2argv-console.args | 2 +- .../bhyvexml2argv-custom-loader.args | 4 +- .../bhyvexml2argv-disk-cdrom-grub.args | 4 +- .../bhyvexml2argv-disk-cdrom.args | 4 +- .../bhyvexml2argv-grub-bootorder.args | 6 +- .../bhyvexml2argv-grub-bootorder2.args | 6 +- .../bhyvexml2argv-grub-defaults.args | 4 +- .../bhyvexml2argvdata/bhyvexml2argv-localtime.args | 4 +- tests/bhyvexml2argvdata/bhyvexml2argv-macaddr.args | 4 +- .../bhyvexml2argv-serial-grub-nocons.args | 2 +- .../bhyvexml2argv-serial-grub.args | 2 +- tests/bhyvexml2argvdata/bhyvexml2argv-serial.args | 2 +- tests/bhyvexml2argvtest.c | 2 +- .../bhyvexml2xmlout-acpiapic.xml | 4 +- tests/bhyvexml2xmloutdata/bhyvexml2xmlout-base.xml | 4 +- .../bhyvexml2xmlout-bhyveload-bootorder.xml | 4 +- .../bhyvexml2xmlout-bhyveload-bootorder1.xml | 4 +- .../bhyvexml2xmlout-bhyveload-bootorder2.xml | 4 +- .../bhyvexml2xmlout-bhyveload-bootorder3.xml | 4 +- .../bhyvexml2xmlout-bhyveload-bootorder4.xml | 4 +- .../bhyvexml2xmlout-bhyveload-explicitargs.xml | 4 +- .../bhyvexml2xmlout-console.xml | 4 +- .../bhyvexml2xmlout-custom-loader.xml | 4 +- .../bhyvexml2xmlout-disk-cdrom-grub.xml | 4 +- .../bhyvexml2xmlout-disk-cdrom.xml | 4 +- .../bhyvexml2xmlout-grub-bootorder.xml | 4 +- .../bhyvexml2xmlout-grub-bootorder2.xml | 4 +- .../bhyvexml2xmlout-grub-defaults.xml | 4 +- .../bhyvexml2xmlout-localtime.xml | 4 +- .../bhyvexml2xmlout-macaddr.xml | 4 +- .../bhyvexml2xmlout-metadata.xml | 5 +- .../bhyvexml2xmlout-serial-grub-nocons.xml | 4 +- .../bhyvexml2xmlout-serial-grub.xml | 4 +- .../bhyvexml2xmloutdata/bhyvexml2xmlout-serial.xml | 4 +- tests/bhyvexml2xmltest.c | 2 + 45 files changed, 279 insertions(+), 118 deletions(-)
diff --git a/po/POTFILES.in b/po/POTFILES.in index e66bb7a3a..632aa7736 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -14,6 +14,7 @@ src/access/viraccessdriverpolkit.c src/access/viraccessmanager.c src/bhyve/bhyve_command.c src/bhyve/bhyve_device.c +src/bhyve/bhyve_domain.c src/bhyve/bhyve_driver.c src/bhyve/bhyve_monitor.c src/bhyve/bhyve_parse_command.c diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c index 8a29977ff..a2fd40378 100644 --- a/src/bhyve/bhyve_command.c +++ b/src/bhyve/bhyve_command.c @@ -148,40 +148,97 @@ bhyveBuildConsoleArgStr(const virDomainDef *def, virCommandPtr cmd) }
static int -bhyveBuildDiskArgStr(const virDomainDef *def ATTRIBUTE_UNUSED, - virDomainDiskDefPtr disk, - virCommandPtr cmd) +bhyveBuildAHCIControllerArgStr(const virDomainDef *def, + virDomainControllerDefPtr controller, + virConnectPtr conn, + virCommandPtr cmd) { - const char *bus_type; + virBuffer buf = VIR_BUFFER_INITIALIZER; + virBuffer device = VIR_BUFFER_INITIALIZER; const char *disk_source; + size_t i; + int ret = -1; + + for (i = 0; i < def->ndisks; i++) { + virDomainDiskDefPtr disk = def->disks[i]; + if (disk->bus != VIR_DOMAIN_DISK_BUS_SATA) + continue; + + if (disk->info.addr.drive.controller != controller->idx) + continue;
Took a minute for me to see why you were doing this - so all the disks attached to a controller are put directly into the controller's commandline arg rather than them being separate args with a ref back to the controller.
True.
+ + VIR_DEBUG("disk %zu controller %d", i, controller->idx); + + if ((virDomainDiskGetType(disk) != VIR_STORAGE_TYPE_FILE) && + (virDomainDiskGetType(disk) != VIR_STORAGE_TYPE_VOLUME)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("unsupported disk type")); + goto error; + } + + if (virStorageTranslateDiskSourcePool(conn, disk) < 0) + goto error; + + disk_source = virDomainDiskGetSource(disk); + + if ((disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM) && + (disk_source == NULL)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("cdrom device without source path " + "not supported")); + goto error; + }
- switch (disk->bus) { - case VIR_DOMAIN_DISK_BUS_SATA: switch (disk->device) { case VIR_DOMAIN_DISK_DEVICE_DISK: - bus_type = "ahci-hd"; + if ((bhyveDriverGetCaps(conn) & BHYVE_CAP_AHCI32SLOT) != 0)
The "!= 0" is superfluous.
Will fix.
+ virBufferAsprintf(&device, ",hd:%s", disk_source); + else + virBufferAsprintf(&device, "-hd,%s", disk_source); break; case VIR_DOMAIN_DISK_DEVICE_CDROM: - bus_type = "ahci-cd"; + if ((bhyveDriverGetCaps(conn) & BHYVE_CAP_AHCI32SLOT) != 0)
Same here.
Will fix it here too.
+ virBufferAsprintf(&device, ",cd:%s", disk_source); + else + virBufferAsprintf(&device, "-cd,%s", disk_source);
It seems like there could be some consolidation of the multiple nearly-identical printf's here. Possibly not worth the trouble though.
break; default: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("unsupported disk device")); - return -1; - } - break; - case VIR_DOMAIN_DISK_BUS_VIRTIO: - if (disk->device == VIR_DOMAIN_DISK_DEVICE_DISK) { - bus_type = "virtio-blk"; - } else { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("unsupported disk device")); - return -1; + goto error; } - break; - default: + virBufferAddBuffer(&buf, &device); + virBufferFreeAndReset(&device); + } + + if (virBufferCheckError(&buf) <0) + goto error; + + virCommandAddArg(cmd, "-s"); + virCommandAddArgFormat(cmd, "%d:0,ahci%s", + controller->info.addr.pci.slot, + virBufferCurrentContent(&buf)); + + ret = 0; + error: + virBufferFreeAndReset(&buf); + return ret; +} + +static int +bhyveBuildVirtIODiskArgStr(const virDomainDef *def ATTRIBUTE_UNUSED, + virDomainDiskDefPtr disk, + virConnectPtr conn, + virCommandPtr cmd) +{ + const char *disk_source; + + if (virStorageTranslateDiskSourcePool(conn, disk) < 0) + return -1; + + if (disk->device != VIR_DOMAIN_DISK_DEVICE_DISK) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("unsupported disk bus type")); + _("unsupported disk device")); return -1; }
@@ -194,17 +251,9 @@ bhyveBuildDiskArgStr(const virDomainDef *def ATTRIBUTE_UNUSED,
disk_source = virDomainDiskGetSource(disk);
- if ((disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM) && - (disk_source == NULL)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("cdrom device without source path " - "not supported")); - return -1; - } - virCommandAddArg(cmd, "-s"); - virCommandAddArgFormat(cmd, "%d:0,%s,%s", - disk->info.addr.pci.slot, bus_type, + virCommandAddArgFormat(cmd, "%d:0,virtio-blk,%s", + disk->info.addr.pci.slot, disk_source);
return 0; @@ -278,6 +327,22 @@ virBhyveProcessBuildBhyveCmd(virConnectPtr conn,
virCommandAddArgList(cmd, "-s", "0:0,hostbridge", NULL); /* Devices */ + for (i = 0; i < def->ncontrollers; i++) { + virDomainControllerDefPtr controller = def->controllers[i]; + switch (controller->type) { + case VIR_DOMAIN_CONTROLLER_TYPE_PCI: + if (controller->model != VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + "%s", _("unsupported PCI controller model: only PCI root supported")); + goto error; + } + break; + case VIR_DOMAIN_CONTROLLER_TYPE_SATA: + if (bhyveBuildAHCIControllerArgStr(def, controller, conn, cmd) < 0) + goto error; + break; + } + } for (i = 0; i < def->nnets; i++) { virDomainNetDefPtr net = def->nets[i]; if (bhyveBuildNetArgStr(def, net, cmd, dryRun) < 0) @@ -286,11 +351,19 @@ virBhyveProcessBuildBhyveCmd(virConnectPtr conn, for (i = 0; i < def->ndisks; i++) { virDomainDiskDefPtr disk = def->disks[i];
- if (virStorageTranslateDiskSourcePool(conn, disk) < 0) - goto error; - - if (bhyveBuildDiskArgStr(def, disk, cmd) < 0) + switch (disk->bus) { + case VIR_DOMAIN_DISK_BUS_SATA: + /* Handled by AHCI controller */ + break;
This is a bit odd, but I see why you're doing it. Maybe you should put the full name of the function (bhyveBuildAHCIControllerArgStr) in the comment rather than just "AHCI controller".
Good idea.
Aside from these minor nits, my only concern is that of compatibility when migrating forward and backward, but since I don't have a system with bhyve I can't test that, so I'll assume that you've done your due diligence in that regard. (Also, I'm assuming that you've successfully run make syntax-check in addition to make check). Based on those assumptions, ACK.
Unfortunately, it's neither forward or backward compatible. I was thinking about preparing a script that strips addresses for the SATA devices so user can undefine/define a domain and let libvirt regenerate the proper addresses. Thanks, Roman Bogorodskiy

Laine Stump wrote:
On 01/05/2017 09:46 AM, Roman Bogorodskiy wrote:
As bhyve for a long time didn't have a notion of the explicit SATA controller and created a controller for each drive, the bhyve driver in libvirt acted in a similar way and didn't care about the SATA controllers and assigned PCI addresses to drives directly, as the generated command will look like this anyway:
2:0,ahci-hd,somedisk.img
This no longer makes sense because:
1. After commit c07d1c1c4f it's not possible to assign PCI addresses to disks 2. Bhyve now supports multiple disk drives for a controller, so it's going away from 1:1 controller:disk mapping, so the controller object starts to make more sense now
So, this patch does the following:
- Assign PCI address to SATA controllers (previously we didn't do this) - Assign disk addresses instead of PCI addresses for disks. Now, when building a bhyve command, we take PCI address not from the disk itself but from its controller - Assign addresses at XML parsing time using the assignAddressesCallback. This is done mainly for being able to verify address allocation via xml2xml tests - Adjust existing bhyvexml2{xml,argv} tests to chase the new address allocation
This patch is largely based on work of Fabian Freyer. --- po/POTFILES.in | 1 + src/bhyve/bhyve_command.c | 143 ++++++++++++++++----- src/bhyve/bhyve_device.c | 33 ++--- src/bhyve/bhyve_domain.c | 60 ++++++++- .../bhyvexml2argvdata/bhyvexml2argv-acpiapic.args | 4 +- tests/bhyvexml2argvdata/bhyvexml2argv-base.args | 4 +- .../bhyvexml2argv-bhyveload-bootorder.args | 5 +- .../bhyvexml2argv-bhyveload-bootorder1.args | 5 +- .../bhyvexml2argv-bhyveload-bootorder3.args | 5 +- .../bhyvexml2argv-bhyveload-explicitargs.args | 4 +- tests/bhyvexml2argvdata/bhyvexml2argv-console.args | 2 +- .../bhyvexml2argv-custom-loader.args | 4 +- .../bhyvexml2argv-disk-cdrom-grub.args | 4 +- .../bhyvexml2argv-disk-cdrom.args | 4 +- .../bhyvexml2argv-grub-bootorder.args | 6 +- .../bhyvexml2argv-grub-bootorder2.args | 6 +- .../bhyvexml2argv-grub-defaults.args | 4 +- .../bhyvexml2argvdata/bhyvexml2argv-localtime.args | 4 +- tests/bhyvexml2argvdata/bhyvexml2argv-macaddr.args | 4 +- .../bhyvexml2argv-serial-grub-nocons.args | 2 +- .../bhyvexml2argv-serial-grub.args | 2 +- tests/bhyvexml2argvdata/bhyvexml2argv-serial.args | 2 +- tests/bhyvexml2argvtest.c | 2 +- .../bhyvexml2xmlout-acpiapic.xml | 4 +- tests/bhyvexml2xmloutdata/bhyvexml2xmlout-base.xml | 4 +- .../bhyvexml2xmlout-bhyveload-bootorder.xml | 4 +- .../bhyvexml2xmlout-bhyveload-bootorder1.xml | 4 +- .../bhyvexml2xmlout-bhyveload-bootorder2.xml | 4 +- .../bhyvexml2xmlout-bhyveload-bootorder3.xml | 4 +- .../bhyvexml2xmlout-bhyveload-bootorder4.xml | 4 +- .../bhyvexml2xmlout-bhyveload-explicitargs.xml | 4 +- .../bhyvexml2xmlout-console.xml | 4 +- .../bhyvexml2xmlout-custom-loader.xml | 4 +- .../bhyvexml2xmlout-disk-cdrom-grub.xml | 4 +- .../bhyvexml2xmlout-disk-cdrom.xml | 4 +- .../bhyvexml2xmlout-grub-bootorder.xml | 4 +- .../bhyvexml2xmlout-grub-bootorder2.xml | 4 +- .../bhyvexml2xmlout-grub-defaults.xml | 4 +- .../bhyvexml2xmlout-localtime.xml | 4 +- .../bhyvexml2xmlout-macaddr.xml | 4 +- .../bhyvexml2xmlout-metadata.xml | 5 +- .../bhyvexml2xmlout-serial-grub-nocons.xml | 4 +- .../bhyvexml2xmlout-serial-grub.xml | 4 +- .../bhyvexml2xmloutdata/bhyvexml2xmlout-serial.xml | 4 +- tests/bhyvexml2xmltest.c | 2 + 45 files changed, 279 insertions(+), 118 deletions(-) Aside from these minor nits, my only concern is that of compatibility when migrating forward and backward, but since I don't have a system with bhyve I can't test that, so I'll assume that you've done your due diligence in that regard. (Also, I'm assuming that you've successfully run make syntax-check in addition to make check). Based on those assumptions, ACK.
I pushed the series, thanks! Roman Bogorodskiy

--- ...bhyvexml2argv-addr-more-than-32-sata-disks.args | 21 ++ ...yvexml2argv-addr-more-than-32-sata-disks.ldargs | 3 + .../bhyvexml2argv-addr-more-than-32-sata-disks.xml | 196 ++++++++++++++++ .../bhyvexml2argv-addr-multiple-sata-disks.args | 9 + .../bhyvexml2argv-addr-multiple-sata-disks.ldargs | 3 + .../bhyvexml2argv-addr-multiple-sata-disks.xml | 31 +++ ...2argv-addr-no32devs-more-than-32-sata-disks.xml | 196 ++++++++++++++++ ...xml2argv-addr-no32devs-multiple-sata-disks.args | 11 + ...l2argv-addr-no32devs-multiple-sata-disks.ldargs | 3 + ...exml2argv-addr-no32devs-multiple-sata-disks.xml | 31 +++ ...yvexml2argv-addr-no32devs-single-sata-disk.args | 9 + ...exml2argv-addr-no32devs-single-sata-disk.ldargs | 3 + ...hyvexml2argv-addr-no32devs-single-sata-disk.xml | 21 ++ .../bhyvexml2argv-addr-single-sata-disk.args | 9 + .../bhyvexml2argv-addr-single-sata-disk.ldargs | 3 + .../bhyvexml2argv-addr-single-sata-disk.xml | 21 ++ .../bhyvexml2argv-serial-grub-nocons.args | 2 +- tests/bhyvexml2argvtest.c | 20 +- ...hyvexml2xmlout-addr-more-than-32-sata-disks.xml | 246 +++++++++++++++++++++ .../bhyvexml2xmlout-addr-multiple-sata-disks.xml | 45 ++++ ...ml2xmlout-addr-no32devs-multiple-sata-disks.xml | 51 +++++ ...vexml2xmlout-addr-no32devs-single-sata-disk.xml | 33 +++ .../bhyvexml2xmlout-addr-single-sata-disk.xml | 33 +++ tests/bhyvexml2xmltest.c | 37 +++- 24 files changed, 1030 insertions(+), 7 deletions(-) create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-addr-more-than-32-sata-disks.args create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-addr-more-than-32-sata-disks.ldargs create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-addr-more-than-32-sata-disks.xml create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-addr-multiple-sata-disks.args create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-addr-multiple-sata-disks.ldargs create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-addr-multiple-sata-disks.xml create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-addr-no32devs-more-than-32-sata-disks.xml create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-addr-no32devs-multiple-sata-disks.args create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-addr-no32devs-multiple-sata-disks.ldargs create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-addr-no32devs-multiple-sata-disks.xml create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-addr-no32devs-single-sata-disk.args create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-addr-no32devs-single-sata-disk.ldargs create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-addr-no32devs-single-sata-disk.xml create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-addr-single-sata-disk.args create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-addr-single-sata-disk.ldargs create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-addr-single-sata-disk.xml create mode 100644 tests/bhyvexml2xmloutdata/bhyvexml2xmlout-addr-more-than-32-sata-disks.xml create mode 100644 tests/bhyvexml2xmloutdata/bhyvexml2xmlout-addr-multiple-sata-disks.xml create mode 100644 tests/bhyvexml2xmloutdata/bhyvexml2xmlout-addr-no32devs-multiple-sata-disks.xml create mode 100644 tests/bhyvexml2xmloutdata/bhyvexml2xmlout-addr-no32devs-single-sata-disk.xml create mode 100644 tests/bhyvexml2xmloutdata/bhyvexml2xmlout-addr-single-sata-disk.xml diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-addr-more-than-32-sata-disks.args b/tests/bhyvexml2argvdata/bhyvexml2argv-addr-more-than-32-sata-disks.args new file mode 100644 index 000000000..d7917bd8f --- /dev/null +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-addr-more-than-32-sata-disks.args @@ -0,0 +1,21 @@ +/usr/sbin/bhyve \ +-c 1 \ +-m 214 \ +-u \ +-H \ +-P \ +-s 0:0,hostbridge \ +-s 2:0,ahci,hd:/tmp/freebsd1.img,hd:/tmp/freebsd2.img,hd:/tmp/freebsd3.img,\ +hd:/tmp/freebsd4.img,hd:/tmp/freebsd5.img,hd:/tmp/freebsd6.img,\ +hd:/tmp/freebsd7.img,hd:/tmp/freebsd8.img,hd:/tmp/freebsd9.img,\ +hd:/tmp/freebsd10.img,hd:/tmp/freebsd11.img,hd:/tmp/freebsd12.img,\ +hd:/tmp/freebsd12.img,hd:/tmp/freebsd13.img,hd:/tmp/freebsd14.img,\ +hd:/tmp/freebsd15.img,hd:/tmp/freebsd16.img,hd:/tmp/freebsd17.img,\ +hd:/tmp/freebsd18.img,hd:/tmp/freebsd19.img,hd:/tmp/freebsd20.img,\ +hd:/tmp/freebsd21.img,hd:/tmp/freebsd22.img,hd:/tmp/freebsd23.img,\ +hd:/tmp/freebsd24.img,hd:/tmp/freebsd25.img,hd:/tmp/freebsd26.img,\ +hd:/tmp/freebsd27.img,hd:/tmp/freebsd28.img,hd:/tmp/freebsd29.img,\ +hd:/tmp/freebsd30.img \ +-s 3:0,ahci,hd:/tmp/freebsd31.img,hd:/tmp/freebsd32.img,hd:/tmp/freebsd33.img,\ +hd:/tmp/freebsd34.img,hd:/tmp/freebsd35.img \ +-s 4:0,virtio-net,faketapdev,mac=52:54:00:b9:94:02 bhyve diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-addr-more-than-32-sata-disks.ldargs b/tests/bhyvexml2argvdata/bhyvexml2argv-addr-more-than-32-sata-disks.ldargs new file mode 100644 index 000000000..70b2224f2 --- /dev/null +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-addr-more-than-32-sata-disks.ldargs @@ -0,0 +1,3 @@ +/usr/sbin/bhyveload \ +-m 214 \ +-d /tmp/freebsd1.img bhyve diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-addr-more-than-32-sata-disks.xml b/tests/bhyvexml2argvdata/bhyvexml2argv-addr-more-than-32-sata-disks.xml new file mode 100644 index 000000000..62d087104 --- /dev/null +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-addr-more-than-32-sata-disks.xml @@ -0,0 +1,196 @@ +<domain type='bhyve'> + <name>bhyve</name> + <uuid>df3be7e7-a104-11e3-aeb0-50e5492bd3dc</uuid> + <memory>219136</memory> + <vcpu>1</vcpu> + <os> + <type>hvm</type> + </os> + <devices> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd1.img'/> + <target dev='hda' bus='sata'/> + </disk> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd2.img'/> + <target dev='hdb' bus='sata'/> + </disk> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd3.img'/> + <target dev='hdc' bus='sata'/> + </disk> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd4.img'/> + <target dev='hdd' bus='sata'/> + </disk> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd5.img'/> + <target dev='hde' bus='sata'/> + </disk> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd6.img'/> + <target dev='hdf' bus='sata'/> + </disk> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd7.img'/> + <target dev='hdg' bus='sata'/> + </disk> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd8.img'/> + <target dev='hdh' bus='sata'/> + </disk> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd9.img'/> + <target dev='hdi' bus='sata'/> + </disk> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd10.img'/> + <target dev='hdj' bus='sata'/> + </disk> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd11.img'/> + <target dev='hdk' bus='sata'/> + </disk> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd12.img'/> + <target dev='hdl' bus='sata'/> + </disk> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd12.img'/> + <target dev='hdm' bus='sata'/> + </disk> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd13.img'/> + <target dev='hdn' bus='sata'/> + </disk> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd14.img'/> + <target dev='hdo' bus='sata'/> + </disk> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd15.img'/> + <target dev='hdp' bus='sata'/> + </disk> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd16.img'/> + <target dev='hdq' bus='sata'/> + </disk> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd17.img'/> + <target dev='hdr' bus='sata'/> + </disk> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd18.img'/> + <target dev='hds' bus='sata'/> + </disk> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd19.img'/> + <target dev='hdt' bus='sata'/> + </disk> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd20.img'/> + <target dev='hdu' bus='sata'/> + </disk> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd21.img'/> + <target dev='hdv' bus='sata'/> + </disk> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd22.img'/> + <target dev='hdw' bus='sata'/> + </disk> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd23.img'/> + <target dev='hdx' bus='sata'/> + </disk> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd24.img'/> + <target dev='hdy' bus='sata'/> + </disk> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd25.img'/> + <target dev='hdz' bus='sata'/> + </disk> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd26.img'/> + <target dev='hdaa' bus='sata'/> + </disk> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd27.img'/> + <target dev='hdab' bus='sata'/> + </disk> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd28.img'/> + <target dev='hdac' bus='sata'/> + </disk> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd29.img'/> + <target dev='hdae' bus='sata'/> + </disk> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd30.img'/> + <target dev='hdaf' bus='sata'/> + </disk> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd31.img'/> + <target dev='hdag' bus='sata'/> + </disk> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd32.img'/> + <target dev='hdah' bus='sata'/> + </disk> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd33.img'/> + <target dev='hdai' bus='sata'/> + </disk> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd34.img'/> + <target dev='hdaj' bus='sata'/> + </disk> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd35.img'/> + <target dev='hdak' bus='sata'/> + </disk> + <interface type='bridge'> + <mac address='52:54:00:b9:94:02'/> + <model type='virtio'/> + <source bridge="virbr0"/> + </interface> + </devices> +</domain> diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-addr-multiple-sata-disks.args b/tests/bhyvexml2argvdata/bhyvexml2argv-addr-multiple-sata-disks.args new file mode 100644 index 000000000..5665842b8 --- /dev/null +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-addr-multiple-sata-disks.args @@ -0,0 +1,9 @@ +/usr/sbin/bhyve \ +-c 1 \ +-m 214 \ +-u \ +-H \ +-P \ +-s 0:0,hostbridge \ +-s 2:0,ahci,hd:/tmp/freebsd1.img,hd:/tmp/freebsd2.img,hd:/tmp/freebsd2.img \ +-s 3:0,virtio-net,faketapdev,mac=52:54:00:b9:94:02 bhyve diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-addr-multiple-sata-disks.ldargs b/tests/bhyvexml2argvdata/bhyvexml2argv-addr-multiple-sata-disks.ldargs new file mode 100644 index 000000000..70b2224f2 --- /dev/null +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-addr-multiple-sata-disks.ldargs @@ -0,0 +1,3 @@ +/usr/sbin/bhyveload \ +-m 214 \ +-d /tmp/freebsd1.img bhyve diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-addr-multiple-sata-disks.xml b/tests/bhyvexml2argvdata/bhyvexml2argv-addr-multiple-sata-disks.xml new file mode 100644 index 000000000..e0c509825 --- /dev/null +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-addr-multiple-sata-disks.xml @@ -0,0 +1,31 @@ +<domain type='bhyve'> + <name>bhyve</name> + <uuid>df3be7e7-a104-11e3-aeb0-50e5492bd3dc</uuid> + <memory>219136</memory> + <vcpu>1</vcpu> + <os> + <type>hvm</type> + </os> + <devices> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd1.img'/> + <target dev='hda' bus='sata'/> + </disk> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd2.img'/> + <target dev='hdb' bus='sata'/> + </disk> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd2.img'/> + <target dev='hdc' bus='sata'/> + </disk> + <interface type='bridge'> + <mac address='52:54:00:b9:94:02'/> + <model type='virtio'/> + <source bridge="virbr0"/> + </interface> + </devices> +</domain> diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-addr-no32devs-more-than-32-sata-disks.xml b/tests/bhyvexml2argvdata/bhyvexml2argv-addr-no32devs-more-than-32-sata-disks.xml new file mode 100644 index 000000000..62d087104 --- /dev/null +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-addr-no32devs-more-than-32-sata-disks.xml @@ -0,0 +1,196 @@ +<domain type='bhyve'> + <name>bhyve</name> + <uuid>df3be7e7-a104-11e3-aeb0-50e5492bd3dc</uuid> + <memory>219136</memory> + <vcpu>1</vcpu> + <os> + <type>hvm</type> + </os> + <devices> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd1.img'/> + <target dev='hda' bus='sata'/> + </disk> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd2.img'/> + <target dev='hdb' bus='sata'/> + </disk> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd3.img'/> + <target dev='hdc' bus='sata'/> + </disk> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd4.img'/> + <target dev='hdd' bus='sata'/> + </disk> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd5.img'/> + <target dev='hde' bus='sata'/> + </disk> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd6.img'/> + <target dev='hdf' bus='sata'/> + </disk> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd7.img'/> + <target dev='hdg' bus='sata'/> + </disk> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd8.img'/> + <target dev='hdh' bus='sata'/> + </disk> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd9.img'/> + <target dev='hdi' bus='sata'/> + </disk> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd10.img'/> + <target dev='hdj' bus='sata'/> + </disk> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd11.img'/> + <target dev='hdk' bus='sata'/> + </disk> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd12.img'/> + <target dev='hdl' bus='sata'/> + </disk> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd12.img'/> + <target dev='hdm' bus='sata'/> + </disk> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd13.img'/> + <target dev='hdn' bus='sata'/> + </disk> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd14.img'/> + <target dev='hdo' bus='sata'/> + </disk> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd15.img'/> + <target dev='hdp' bus='sata'/> + </disk> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd16.img'/> + <target dev='hdq' bus='sata'/> + </disk> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd17.img'/> + <target dev='hdr' bus='sata'/> + </disk> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd18.img'/> + <target dev='hds' bus='sata'/> + </disk> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd19.img'/> + <target dev='hdt' bus='sata'/> + </disk> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd20.img'/> + <target dev='hdu' bus='sata'/> + </disk> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd21.img'/> + <target dev='hdv' bus='sata'/> + </disk> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd22.img'/> + <target dev='hdw' bus='sata'/> + </disk> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd23.img'/> + <target dev='hdx' bus='sata'/> + </disk> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd24.img'/> + <target dev='hdy' bus='sata'/> + </disk> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd25.img'/> + <target dev='hdz' bus='sata'/> + </disk> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd26.img'/> + <target dev='hdaa' bus='sata'/> + </disk> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd27.img'/> + <target dev='hdab' bus='sata'/> + </disk> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd28.img'/> + <target dev='hdac' bus='sata'/> + </disk> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd29.img'/> + <target dev='hdae' bus='sata'/> + </disk> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd30.img'/> + <target dev='hdaf' bus='sata'/> + </disk> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd31.img'/> + <target dev='hdag' bus='sata'/> + </disk> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd32.img'/> + <target dev='hdah' bus='sata'/> + </disk> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd33.img'/> + <target dev='hdai' bus='sata'/> + </disk> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd34.img'/> + <target dev='hdaj' bus='sata'/> + </disk> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd35.img'/> + <target dev='hdak' bus='sata'/> + </disk> + <interface type='bridge'> + <mac address='52:54:00:b9:94:02'/> + <model type='virtio'/> + <source bridge="virbr0"/> + </interface> + </devices> +</domain> diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-addr-no32devs-multiple-sata-disks.args b/tests/bhyvexml2argvdata/bhyvexml2argv-addr-no32devs-multiple-sata-disks.args new file mode 100644 index 000000000..03bf381ff --- /dev/null +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-addr-no32devs-multiple-sata-disks.args @@ -0,0 +1,11 @@ +/usr/sbin/bhyve \ +-c 1 \ +-m 214 \ +-u \ +-H \ +-P \ +-s 0:0,hostbridge \ +-s 2:0,ahci-hd,/tmp/freebsd1.img \ +-s 3:0,ahci-hd,/tmp/freebsd2.img \ +-s 4:0,ahci-hd,/tmp/freebsd2.img \ +-s 5:0,virtio-net,faketapdev,mac=52:54:00:b9:94:02 bhyve diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-addr-no32devs-multiple-sata-disks.ldargs b/tests/bhyvexml2argvdata/bhyvexml2argv-addr-no32devs-multiple-sata-disks.ldargs new file mode 100644 index 000000000..70b2224f2 --- /dev/null +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-addr-no32devs-multiple-sata-disks.ldargs @@ -0,0 +1,3 @@ +/usr/sbin/bhyveload \ +-m 214 \ +-d /tmp/freebsd1.img bhyve diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-addr-no32devs-multiple-sata-disks.xml b/tests/bhyvexml2argvdata/bhyvexml2argv-addr-no32devs-multiple-sata-disks.xml new file mode 100644 index 000000000..e0c509825 --- /dev/null +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-addr-no32devs-multiple-sata-disks.xml @@ -0,0 +1,31 @@ +<domain type='bhyve'> + <name>bhyve</name> + <uuid>df3be7e7-a104-11e3-aeb0-50e5492bd3dc</uuid> + <memory>219136</memory> + <vcpu>1</vcpu> + <os> + <type>hvm</type> + </os> + <devices> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd1.img'/> + <target dev='hda' bus='sata'/> + </disk> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd2.img'/> + <target dev='hdb' bus='sata'/> + </disk> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd2.img'/> + <target dev='hdc' bus='sata'/> + </disk> + <interface type='bridge'> + <mac address='52:54:00:b9:94:02'/> + <model type='virtio'/> + <source bridge="virbr0"/> + </interface> + </devices> +</domain> diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-addr-no32devs-single-sata-disk.args b/tests/bhyvexml2argvdata/bhyvexml2argv-addr-no32devs-single-sata-disk.args new file mode 100644 index 000000000..d51924135 --- /dev/null +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-addr-no32devs-single-sata-disk.args @@ -0,0 +1,9 @@ +/usr/sbin/bhyve \ +-c 1 \ +-m 214 \ +-u \ +-H \ +-P \ +-s 0:0,hostbridge \ +-s 2:0,ahci-hd,/tmp/freebsd.img \ +-s 3:0,virtio-net,faketapdev,mac=52:54:00:b9:94:02 bhyve diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-addr-no32devs-single-sata-disk.ldargs b/tests/bhyvexml2argvdata/bhyvexml2argv-addr-no32devs-single-sata-disk.ldargs new file mode 100644 index 000000000..32538b558 --- /dev/null +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-addr-no32devs-single-sata-disk.ldargs @@ -0,0 +1,3 @@ +/usr/sbin/bhyveload \ +-m 214 \ +-d /tmp/freebsd.img bhyve diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-addr-no32devs-single-sata-disk.xml b/tests/bhyvexml2argvdata/bhyvexml2argv-addr-no32devs-single-sata-disk.xml new file mode 100644 index 000000000..47bb47154 --- /dev/null +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-addr-no32devs-single-sata-disk.xml @@ -0,0 +1,21 @@ +<domain type='bhyve'> + <name>bhyve</name> + <uuid>df3be7e7-a104-11e3-aeb0-50e5492bd3dc</uuid> + <memory>219136</memory> + <vcpu>1</vcpu> + <os> + <type>hvm</type> + </os> + <devices> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd.img'/> + <target dev='hda' bus='sata'/> + </disk> + <interface type='bridge'> + <mac address='52:54:00:b9:94:02'/> + <model type='virtio'/> + <source bridge="virbr0"/> + </interface> + </devices> +</domain> diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-addr-single-sata-disk.args b/tests/bhyvexml2argvdata/bhyvexml2argv-addr-single-sata-disk.args new file mode 100644 index 000000000..547485ba5 --- /dev/null +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-addr-single-sata-disk.args @@ -0,0 +1,9 @@ +/usr/sbin/bhyve \ +-c 1 \ +-m 214 \ +-u \ +-H \ +-P \ +-s 0:0,hostbridge \ +-s 2:0,ahci,hd:/tmp/freebsd.img \ +-s 3:0,virtio-net,faketapdev,mac=52:54:00:b9:94:02 bhyve diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-addr-single-sata-disk.ldargs b/tests/bhyvexml2argvdata/bhyvexml2argv-addr-single-sata-disk.ldargs new file mode 100644 index 000000000..32538b558 --- /dev/null +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-addr-single-sata-disk.ldargs @@ -0,0 +1,3 @@ +/usr/sbin/bhyveload \ +-m 214 \ +-d /tmp/freebsd.img bhyve diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-addr-single-sata-disk.xml b/tests/bhyvexml2argvdata/bhyvexml2argv-addr-single-sata-disk.xml new file mode 100644 index 000000000..47bb47154 --- /dev/null +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-addr-single-sata-disk.xml @@ -0,0 +1,21 @@ +<domain type='bhyve'> + <name>bhyve</name> + <uuid>df3be7e7-a104-11e3-aeb0-50e5492bd3dc</uuid> + <memory>219136</memory> + <vcpu>1</vcpu> + <os> + <type>hvm</type> + </os> + <devices> + <disk type='file'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd.img'/> + <target dev='hda' bus='sata'/> + </disk> + <interface type='bridge'> + <mac address='52:54:00:b9:94:02'/> + <model type='virtio'/> + <source bridge="virbr0"/> + </interface> + </devices> +</domain> diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub-nocons.args b/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub-nocons.args index ff69ed3a7..42a278208 100644 --- a/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub-nocons.args +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-serial-grub-nocons.args @@ -5,7 +5,7 @@ -H \ -P \ -s 0:0,hostbridge \ --s 2:0,ahci,hd:/tmp/freebsd.img \ +-s 2:0,ahci-hd,/tmp/freebsd.img \ -s 3:0,virtio-net,faketapdev,mac=52:54:00:a7:cd:5b \ -s 1,lpc \ -l com1,/dev/nmdm0A bhyve diff --git a/tests/bhyvexml2argvtest.c b/tests/bhyvexml2argvtest.c index 6d0a9e1f8..e80705780 100644 --- a/tests/bhyvexml2argvtest.c +++ b/tests/bhyvexml2argvtest.c @@ -37,8 +37,15 @@ static int testCompareXMLToArgvFiles(const char *xml, if (!(vmdef = virDomainDefParseFile(xml, driver.caps, driver.xmlopt, NULL, VIR_DOMAIN_DEF_PARSE_INACTIVE))) { - if (flags & FLAG_EXPECT_PARSE_ERROR) + if (flags & FLAG_EXPECT_PARSE_ERROR) { ret = 0; + } else if (flags & FLAG_EXPECT_FAILURE) { + ret = 0; + VIR_TEST_DEBUG("Got expected error: %s\n", + virGetLastErrorMessage()); + virResetLastError(); + } + goto out; } @@ -179,6 +186,17 @@ mymain(void) DO_TEST("serial-grub"); DO_TEST("localtime"); + /* Address allocation tests */ + DO_TEST("addr-single-sata-disk"); + DO_TEST("addr-multiple-sata-disks"); + DO_TEST("addr-more-than-32-sata-disks"); + + /* The same without 32 devs per controller support */ + driver.bhyvecaps ^= BHYVE_CAP_AHCI32SLOT; + DO_TEST("addr-no32devs-single-sata-disk"); + DO_TEST("addr-no32devs-multiple-sata-disks"); + DO_TEST_FAILURE("addr-no32devs-more-than-32-sata-disks"); + driver.grubcaps = 0; DO_TEST("serial-grub-nocons"); diff --git a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-addr-more-than-32-sata-disks.xml b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-addr-more-than-32-sata-disks.xml new file mode 100644 index 000000000..ac3799936 --- /dev/null +++ b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-addr-more-than-32-sata-disks.xml @@ -0,0 +1,246 @@ +<domain type='bhyve'> + <name>bhyve</name> + <uuid>df3be7e7-a104-11e3-aeb0-50e5492bd3dc</uuid> + <memory unit='KiB'>219136</memory> + <currentMemory unit='KiB'>219136</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='x86_64'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <disk type='file' device='disk'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd1.img'/> + <target dev='hda' bus='sata'/> + <address type='drive' controller='0' bus='0' target='0' unit='0'/> + </disk> + <disk type='file' device='disk'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd2.img'/> + <target dev='hdb' bus='sata'/> + <address type='drive' controller='0' bus='0' target='0' unit='1'/> + </disk> + <disk type='file' device='disk'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd3.img'/> + <target dev='hdc' bus='sata'/> + <address type='drive' controller='0' bus='0' target='0' unit='2'/> + </disk> + <disk type='file' device='disk'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd4.img'/> + <target dev='hdd' bus='sata'/> + <address type='drive' controller='0' bus='0' target='0' unit='3'/> + </disk> + <disk type='file' device='disk'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd5.img'/> + <target dev='hde' bus='sata'/> + <address type='drive' controller='0' bus='0' target='0' unit='4'/> + </disk> + <disk type='file' device='disk'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd6.img'/> + <target dev='hdf' bus='sata'/> + <address type='drive' controller='0' bus='0' target='0' unit='5'/> + </disk> + <disk type='file' device='disk'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd7.img'/> + <target dev='hdg' bus='sata'/> + <address type='drive' controller='0' bus='0' target='0' unit='6'/> + </disk> + <disk type='file' device='disk'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd8.img'/> + <target dev='hdh' bus='sata'/> + <address type='drive' controller='0' bus='0' target='0' unit='7'/> + </disk> + <disk type='file' device='disk'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd9.img'/> + <target dev='hdi' bus='sata'/> + <address type='drive' controller='0' bus='0' target='0' unit='8'/> + </disk> + <disk type='file' device='disk'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd10.img'/> + <target dev='hdj' bus='sata'/> + <address type='drive' controller='0' bus='0' target='0' unit='9'/> + </disk> + <disk type='file' device='disk'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd11.img'/> + <target dev='hdk' bus='sata'/> + <address type='drive' controller='0' bus='0' target='0' unit='10'/> + </disk> + <disk type='file' device='disk'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd12.img'/> + <target dev='hdl' bus='sata'/> + <address type='drive' controller='0' bus='0' target='0' unit='11'/> + </disk> + <disk type='file' device='disk'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd12.img'/> + <target dev='hdm' bus='sata'/> + <address type='drive' controller='0' bus='0' target='0' unit='12'/> + </disk> + <disk type='file' device='disk'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd13.img'/> + <target dev='hdn' bus='sata'/> + <address type='drive' controller='0' bus='0' target='0' unit='13'/> + </disk> + <disk type='file' device='disk'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd14.img'/> + <target dev='hdo' bus='sata'/> + <address type='drive' controller='0' bus='0' target='0' unit='14'/> + </disk> + <disk type='file' device='disk'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd15.img'/> + <target dev='hdp' bus='sata'/> + <address type='drive' controller='0' bus='0' target='0' unit='15'/> + </disk> + <disk type='file' device='disk'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd16.img'/> + <target dev='hdq' bus='sata'/> + <address type='drive' controller='0' bus='0' target='0' unit='16'/> + </disk> + <disk type='file' device='disk'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd17.img'/> + <target dev='hdr' bus='sata'/> + <address type='drive' controller='0' bus='0' target='0' unit='17'/> + </disk> + <disk type='file' device='disk'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd18.img'/> + <target dev='hds' bus='sata'/> + <address type='drive' controller='0' bus='0' target='0' unit='18'/> + </disk> + <disk type='file' device='disk'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd19.img'/> + <target dev='hdt' bus='sata'/> + <address type='drive' controller='0' bus='0' target='0' unit='19'/> + </disk> + <disk type='file' device='disk'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd20.img'/> + <target dev='hdu' bus='sata'/> + <address type='drive' controller='0' bus='0' target='0' unit='20'/> + </disk> + <disk type='file' device='disk'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd21.img'/> + <target dev='hdv' bus='sata'/> + <address type='drive' controller='0' bus='0' target='0' unit='21'/> + </disk> + <disk type='file' device='disk'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd22.img'/> + <target dev='hdw' bus='sata'/> + <address type='drive' controller='0' bus='0' target='0' unit='22'/> + </disk> + <disk type='file' device='disk'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd23.img'/> + <target dev='hdx' bus='sata'/> + <address type='drive' controller='0' bus='0' target='0' unit='23'/> + </disk> + <disk type='file' device='disk'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd24.img'/> + <target dev='hdy' bus='sata'/> + <address type='drive' controller='0' bus='0' target='0' unit='24'/> + </disk> + <disk type='file' device='disk'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd25.img'/> + <target dev='hdz' bus='sata'/> + <address type='drive' controller='0' bus='0' target='0' unit='25'/> + </disk> + <disk type='file' device='disk'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd26.img'/> + <target dev='hdaa' bus='sata'/> + <address type='drive' controller='0' bus='0' target='0' unit='26'/> + </disk> + <disk type='file' device='disk'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd27.img'/> + <target dev='hdab' bus='sata'/> + <address type='drive' controller='0' bus='0' target='0' unit='27'/> + </disk> + <disk type='file' device='disk'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd28.img'/> + <target dev='hdac' bus='sata'/> + <address type='drive' controller='0' bus='0' target='0' unit='28'/> + </disk> + <disk type='file' device='disk'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd29.img'/> + <target dev='hdae' bus='sata'/> + <address type='drive' controller='0' bus='0' target='0' unit='30'/> + </disk> + <disk type='file' device='disk'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd30.img'/> + <target dev='hdaf' bus='sata'/> + <address type='drive' controller='0' bus='0' target='0' unit='31'/> + </disk> + <disk type='file' device='disk'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd31.img'/> + <target dev='hdag' bus='sata'/> + <address type='drive' controller='1' bus='0' target='0' unit='0'/> + </disk> + <disk type='file' device='disk'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd32.img'/> + <target dev='hdah' bus='sata'/> + <address type='drive' controller='1' bus='0' target='0' unit='1'/> + </disk> + <disk type='file' device='disk'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd33.img'/> + <target dev='hdai' bus='sata'/> + <address type='drive' controller='1' bus='0' target='0' unit='2'/> + </disk> + <disk type='file' device='disk'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd34.img'/> + <target dev='hdaj' bus='sata'/> + <address type='drive' controller='1' bus='0' target='0' unit='3'/> + </disk> + <disk type='file' device='disk'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd35.img'/> + <target dev='hdak' bus='sata'/> + <address type='drive' controller='1' bus='0' target='0' unit='4'/> + </disk> + <controller type='pci' index='0' model='pci-root'/> + <controller type='sata' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> + </controller> + <controller type='sata' index='1'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> + </controller> + <interface type='bridge'> + <mac address='52:54:00:b9:94:02'/> + <source bridge='virbr0'/> + <model type='virtio'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> + </interface> + </devices> +</domain> diff --git a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-addr-multiple-sata-disks.xml b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-addr-multiple-sata-disks.xml new file mode 100644 index 000000000..ac4cbb4ea --- /dev/null +++ b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-addr-multiple-sata-disks.xml @@ -0,0 +1,45 @@ +<domain type='bhyve'> + <name>bhyve</name> + <uuid>df3be7e7-a104-11e3-aeb0-50e5492bd3dc</uuid> + <memory unit='KiB'>219136</memory> + <currentMemory unit='KiB'>219136</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='x86_64'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <disk type='file' device='disk'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd1.img'/> + <target dev='hda' bus='sata'/> + <address type='drive' controller='0' bus='0' target='0' unit='0'/> + </disk> + <disk type='file' device='disk'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd2.img'/> + <target dev='hdb' bus='sata'/> + <address type='drive' controller='0' bus='0' target='0' unit='1'/> + </disk> + <disk type='file' device='disk'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd2.img'/> + <target dev='hdc' bus='sata'/> + <address type='drive' controller='0' bus='0' target='0' unit='2'/> + </disk> + <controller type='pci' index='0' model='pci-root'/> + <controller type='sata' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> + </controller> + <interface type='bridge'> + <mac address='52:54:00:b9:94:02'/> + <source bridge='virbr0'/> + <model type='virtio'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> + </interface> + </devices> +</domain> diff --git a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-addr-no32devs-multiple-sata-disks.xml b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-addr-no32devs-multiple-sata-disks.xml new file mode 100644 index 000000000..e4be4b9a4 --- /dev/null +++ b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-addr-no32devs-multiple-sata-disks.xml @@ -0,0 +1,51 @@ +<domain type='bhyve'> + <name>bhyve</name> + <uuid>df3be7e7-a104-11e3-aeb0-50e5492bd3dc</uuid> + <memory unit='KiB'>219136</memory> + <currentMemory unit='KiB'>219136</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='x86_64'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <disk type='file' device='disk'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd1.img'/> + <target dev='hda' bus='sata'/> + <address type='drive' controller='0' bus='0' target='0' unit='0'/> + </disk> + <disk type='file' device='disk'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd2.img'/> + <target dev='hdb' bus='sata'/> + <address type='drive' controller='1' bus='0' target='0' unit='0'/> + </disk> + <disk type='file' device='disk'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd2.img'/> + <target dev='hdc' bus='sata'/> + <address type='drive' controller='2' bus='0' target='0' unit='0'/> + </disk> + <controller type='pci' index='0' model='pci-root'/> + <controller type='sata' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> + </controller> + <controller type='sata' index='1'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> + </controller> + <controller type='sata' index='2'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/> + </controller> + <interface type='bridge'> + <mac address='52:54:00:b9:94:02'/> + <source bridge='virbr0'/> + <model type='virtio'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/> + </interface> + </devices> +</domain> diff --git a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-addr-no32devs-single-sata-disk.xml b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-addr-no32devs-single-sata-disk.xml new file mode 100644 index 000000000..53fa67a3e --- /dev/null +++ b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-addr-no32devs-single-sata-disk.xml @@ -0,0 +1,33 @@ +<domain type='bhyve'> + <name>bhyve</name> + <uuid>df3be7e7-a104-11e3-aeb0-50e5492bd3dc</uuid> + <memory unit='KiB'>219136</memory> + <currentMemory unit='KiB'>219136</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='x86_64'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <disk type='file' device='disk'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd.img'/> + <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'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> + </controller> + <interface type='bridge'> + <mac address='52:54:00:b9:94:02'/> + <source bridge='virbr0'/> + <model type='virtio'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> + </interface> + </devices> +</domain> diff --git a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-addr-single-sata-disk.xml b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-addr-single-sata-disk.xml new file mode 100644 index 000000000..53fa67a3e --- /dev/null +++ b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-addr-single-sata-disk.xml @@ -0,0 +1,33 @@ +<domain type='bhyve'> + <name>bhyve</name> + <uuid>df3be7e7-a104-11e3-aeb0-50e5492bd3dc</uuid> + <memory unit='KiB'>219136</memory> + <currentMemory unit='KiB'>219136</currentMemory> + <vcpu placement='static'>1</vcpu> + <os> + <type arch='x86_64'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <disk type='file' device='disk'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd.img'/> + <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'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> + </controller> + <interface type='bridge'> + <mac address='52:54:00:b9:94:02'/> + <source bridge='virbr0'/> + <model type='virtio'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> + </interface> + </devices> +</domain> diff --git a/tests/bhyvexml2xmltest.c b/tests/bhyvexml2xmltest.c index 93ab3800c..004afda14 100644 --- a/tests/bhyvexml2xmltest.c +++ b/tests/bhyvexml2xmltest.c @@ -14,15 +14,21 @@ static bhyveConn driver; struct testInfo { const char *name; - bool different; + unsigned int flags; }; +typedef enum { + FLAG_IS_DIFFERENT = 1 << 0, + FLAG_EXPECT_FAILURE = 1 << 1, +} virBhyveXMLToXMLTestFlags; + static int testCompareXMLToXMLHelper(const void *data) { const struct testInfo *info = data; char *xml_in = NULL; char *xml_out = NULL; + bool is_different = info->flags & FLAG_IS_DIFFERENT; int ret = -1; if (virAsprintf(&xml_in, "%s/bhyvexml2argvdata/bhyvexml2argv-%s.xml", @@ -32,10 +38,17 @@ testCompareXMLToXMLHelper(const void *data) goto cleanup; ret = testCompareDomXML2XMLFiles(driver.caps, driver.xmlopt, xml_in, - info->different ? xml_out : xml_in, + is_different ? xml_out : xml_in, false, NULL, NULL, 0, TEST_COMPARE_DOM_XML2XML_RESULT_SUCCESS); + if ((ret != 0) && (info->flags & FLAG_EXPECT_FAILURE)) { + ret = 0; + VIR_TEST_DEBUG("Got expected error: %s\n", + virGetLastErrorMessage()); + virResetLastError(); + } + cleanup: VIR_FREE(xml_in); VIR_FREE(xml_out); @@ -53,16 +66,19 @@ mymain(void) if ((driver.xmlopt = virBhyveDriverCreateXMLConf(&driver)) == NULL) return EXIT_FAILURE; -# define DO_TEST_FULL(name, is_different) \ +# define DO_TEST_FULL(name, flags) \ do { \ - const struct testInfo info = {name, is_different}; \ + const struct testInfo info = {name, (flags)}; \ if (virTestRun("BHYVE XML-2-XML " name, \ testCompareXMLToXMLHelper, &info) < 0) \ ret = -1; \ } while (0) # define DO_TEST_DIFFERENT(name) \ - DO_TEST_FULL(name, true) + DO_TEST_FULL(name, FLAG_IS_DIFFERENT) + +# define DO_TEST_FAILURE(name) \ + DO_TEST_FULL(name, FLAG_EXPECT_FAILURE) driver.bhyvecaps = BHYVE_CAP_AHCI32SLOT; @@ -89,6 +105,17 @@ mymain(void) DO_TEST_DIFFERENT("serial-grub"); DO_TEST_DIFFERENT("serial-grub-nocons"); + /* Address allocation tests */ + DO_TEST_DIFFERENT("addr-single-sata-disk"); + DO_TEST_DIFFERENT("addr-multiple-sata-disks"); + DO_TEST_DIFFERENT("addr-more-than-32-sata-disks"); + + /* The same without 32 devs per controller support */ + driver.bhyvecaps ^= BHYVE_CAP_AHCI32SLOT; + DO_TEST_DIFFERENT("addr-no32devs-single-sata-disk"); + DO_TEST_DIFFERENT("addr-no32devs-multiple-sata-disks"); + DO_TEST_FAILURE("addr-no32devs-more-than-32-sata-disks"); + virObjectUnref(driver.caps); virObjectUnref(driver.xmlopt); -- 2.11.0

On 01/05/2017 09:46 AM, Roman Bogorodskiy wrote:
--- ...bhyvexml2argv-addr-more-than-32-sata-disks.args | 21 ++ ...yvexml2argv-addr-more-than-32-sata-disks.ldargs | 3 + .../bhyvexml2argv-addr-more-than-32-sata-disks.xml | 196 ++++++++++++++++ .../bhyvexml2argv-addr-multiple-sata-disks.args | 9 + .../bhyvexml2argv-addr-multiple-sata-disks.ldargs | 3 + .../bhyvexml2argv-addr-multiple-sata-disks.xml | 31 +++ ...2argv-addr-no32devs-more-than-32-sata-disks.xml | 196 ++++++++++++++++ ...xml2argv-addr-no32devs-multiple-sata-disks.args | 11 + ...l2argv-addr-no32devs-multiple-sata-disks.ldargs | 3 + ...exml2argv-addr-no32devs-multiple-sata-disks.xml | 31 +++ ...yvexml2argv-addr-no32devs-single-sata-disk.args | 9 + ...exml2argv-addr-no32devs-single-sata-disk.ldargs | 3 + ...hyvexml2argv-addr-no32devs-single-sata-disk.xml | 21 ++ .../bhyvexml2argv-addr-single-sata-disk.args | 9 + .../bhyvexml2argv-addr-single-sata-disk.ldargs | 3 + .../bhyvexml2argv-addr-single-sata-disk.xml | 21 ++ .../bhyvexml2argv-serial-grub-nocons.args | 2 +- tests/bhyvexml2argvtest.c | 20 +- ...hyvexml2xmlout-addr-more-than-32-sata-disks.xml | 246 +++++++++++++++++++++ .../bhyvexml2xmlout-addr-multiple-sata-disks.xml | 45 ++++ ...ml2xmlout-addr-no32devs-multiple-sata-disks.xml | 51 +++++ ...vexml2xmlout-addr-no32devs-single-sata-disk.xml | 33 +++ .../bhyvexml2xmlout-addr-single-sata-disk.xml | 33 +++ tests/bhyvexml2xmltest.c | 37 +++- 24 files changed, 1030 insertions(+), 7 deletions(-) create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-addr-more-than-32-sata-disks.args create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-addr-more-than-32-sata-disks.ldargs create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-addr-more-than-32-sata-disks.xml create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-addr-multiple-sata-disks.args create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-addr-multiple-sata-disks.ldargs create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-addr-multiple-sata-disks.xml create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-addr-no32devs-more-than-32-sata-disks.xml create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-addr-no32devs-multiple-sata-disks.args create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-addr-no32devs-multiple-sata-disks.ldargs create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-addr-no32devs-multiple-sata-disks.xml create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-addr-no32devs-single-sata-disk.args create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-addr-no32devs-single-sata-disk.ldargs create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-addr-no32devs-single-sata-disk.xml create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-addr-single-sata-disk.args create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-addr-single-sata-disk.ldargs create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-addr-single-sata-disk.xml create mode 100644 tests/bhyvexml2xmloutdata/bhyvexml2xmlout-addr-more-than-32-sata-disks.xml create mode 100644 tests/bhyvexml2xmloutdata/bhyvexml2xmlout-addr-multiple-sata-disks.xml create mode 100644 tests/bhyvexml2xmloutdata/bhyvexml2xmlout-addr-no32devs-multiple-sata-disks.xml create mode 100644 tests/bhyvexml2xmloutdata/bhyvexml2xmlout-addr-no32devs-single-sata-disk.xml create mode 100644 tests/bhyvexml2xmloutdata/bhyvexml2xmlout-addr-single-sata-disk.xml
ACK. [...]
+ <disk type='file' device='disk'> + <driver name='file' type='raw'/> + <source file='/tmp/freebsd29.img'/> + <target dev='hdae' bus='sata'/> + <address type='drive' controller='0' bus='0' target='0' unit='30'/> + </disk>
It's a pre-existing condition, but it has always bothered me that we require the target dev attribute, but it is never used for anything on qemu, and apparently on bhyve as well (if I recall correctly, it *is* used on lxc and xen). More bothersome is that it can lead people to believe that they *can* set the name of the device in the guest when actually they can't - it isn't even a *suggestion*, but completely ignored (similar to how the "bus" attribute of a PCI address misleads some people into believing they can set the bus number for a PCI controller, when in reality it's just used internally by libvirt to associate a device with a controller)

Roman Bogorodskiy wrote:
This series reworks SATA address allocation in the bhyve driver.
While commit messages provide enough details (I hope), there are some general important notes:
- currently, sata devices get PCI addresses and this no longer works, so right now bhyve driver fails on any SATA device - While this series fixes SATA devices' addresses (I hope *again*), old Domain XMLs with already generated PCI addresses will not work. Also, it will not work for XMLs where user manually specified PCI address for a disk, though it worked before. This is not good and I'm open for suggestions how to handle that. I'm thinking about writing a tiny Python script that will drop incorrect addresses from domain XMLs.
Fabian Freyer (1): bhyve: detect 32 SATA devices per controller support
Roman Bogorodskiy (3): bhyve: add virBhyveDriverCreateXMLConf bhyve: fix SATA address allocation bhyve: add tests for SATA address allocation
Ping? While it doesn't seem likely that there's a chance to get that in the upcoming release because even if this is fine as it as, I still need to properly test at least basic domain XML migration across releases, but it'd be cool to have this landed in the beginning of the next release cycle. Roman Bogorodskiy

Roman Bogorodskiy wrote:
Roman Bogorodskiy wrote:
This series reworks SATA address allocation in the bhyve driver.
While commit messages provide enough details (I hope), there are some general important notes:
- currently, sata devices get PCI addresses and this no longer works, so right now bhyve driver fails on any SATA device - While this series fixes SATA devices' addresses (I hope *again*), old Domain XMLs with already generated PCI addresses will not work. Also, it will not work for XMLs where user manually specified PCI address for a disk, though it worked before. This is not good and I'm open for suggestions how to handle that. I'm thinking about writing a tiny Python script that will drop incorrect addresses from domain XMLs.
Fabian Freyer (1): bhyve: detect 32 SATA devices per controller support
Roman Bogorodskiy (3): bhyve: add virBhyveDriverCreateXMLConf bhyve: fix SATA address allocation bhyve: add tests for SATA address allocation
Ping?
While it doesn't seem likely that there's a chance to get that in the upcoming release because even if this is fine as it as, I still need to properly test at least basic domain XML migration across releases, but it'd be cool to have this landed in the beginning of the next release cycle.
Ping? Roman Bogorodskiy

On Thu, 2017-01-05 at 18:46 +0400, Roman Bogorodskiy wrote:
This series reworks SATA address allocation in the bhyve driver.
While commit messages provide enough details (I hope), there are some general important notes:
- currently, sata devices get PCI addresses and this no longer works, so right now bhyve driver fails on any SATA device - While this series fixes SATA devices' addresses (I hope *again*), old Domain XMLs with already generated PCI addresses will not work. Also, it will not work for XMLs where user manually specified PCI address for a disk, though it worked before. This is not good and I'm open for suggestions how to handle that. I'm thinking about writing a tiny Python script that will drop incorrect addresses from domain XMLs.
Fabian Freyer (1): bhyve: detect 32 SATA devices per controller support
Roman Bogorodskiy (3): bhyve: add virBhyveDriverCreateXMLConf bhyve: fix SATA address allocation bhyve: add tests for SATA address allocation
Please don't forget to document these changes in the Release Notes :) -- Andrea Bolognani / Red Hat / Virtualization

Andrea Bolognani wrote:
On Thu, 2017-01-05 at 18:46 +0400, Roman Bogorodskiy wrote:
This series reworks SATA address allocation in the bhyve driver.
While commit messages provide enough details (I hope), there are some general important notes:
- currently, sata devices get PCI addresses and this no longer works, so right now bhyve driver fails on any SATA device - While this series fixes SATA devices' addresses (I hope *again*), old Domain XMLs with already generated PCI addresses will not work. Also, it will not work for XMLs where user manually specified PCI address for a disk, though it worked before. This is not good and I'm open for suggestions how to handle that. I'm thinking about writing a tiny Python script that will drop incorrect addresses from domain XMLs.
Fabian Freyer (1): bhyve: detect 32 SATA devices per controller support
Roman Bogorodskiy (3): bhyve: add virBhyveDriverCreateXMLConf bhyve: fix SATA address allocation bhyve: add tests for SATA address allocation
Please don't forget to document these changes in the Release Notes :)
Yeah, sure. Though I'm planning to write a script first that'll fix domain XMLs for easy migration from the old to the new addressing schema (and back) so I could mention that in the notes. Roman Bogorodskiy
participants (4)
-
Andrea Bolognani
-
Fabian Freyer
-
Laine Stump
-
Roman Bogorodskiy