[libvirt] [PATCH 1/2] bhyve: add support for virtio block devices

--- src/bhyve/bhyve_command.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c index b9df6d0..2ec97fc 100644 --- a/src/bhyve/bhyve_command.c +++ b/src/bhyve/bhyve_command.c @@ -216,6 +216,7 @@ static int bhyveBuildDiskArgStr(const virDomainDef *def, virCommandPtr cmd) { virDomainDiskDefPtr disk; + const char *bus_type; if (def->ndisks != 1) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", @@ -225,7 +226,14 @@ bhyveBuildDiskArgStr(const virDomainDef *def, virCommandPtr cmd) disk = def->disks[0]; - if (disk->bus != VIR_DOMAIN_DISK_BUS_SATA) { + switch (disk->bus) { + case VIR_DOMAIN_DISK_BUS_SATA: + bus_type = "ahci-hd"; + break; + case VIR_DOMAIN_DISK_BUS_VIRTIO: + bus_type = "virtio-blk"; + break; + default: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("unsupported disk bus type")); return -1; @@ -244,7 +252,7 @@ bhyveBuildDiskArgStr(const virDomainDef *def, virCommandPtr cmd) } virCommandAddArg(cmd, "-s"); - virCommandAddArgFormat(cmd, "2:0,ahci-hd,%s", disk->src); + virCommandAddArgFormat(cmd, "2:0,%s,%s", bus_type, disk->src); return 0; } -- 1.8.4.2

Addition of the hostbridge device was mistakenly placed to bhyveBuildNetArgStr(). This could result in hostbridge device not being added to the commandline if there are no network devices specified, but hostbridge device should be added unconditionally. Fix by placing it to virBhyveProcessBuildBhyveCmd(). --- src/bhyve/bhyve_command.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c index 2ec97fc..9fc68ae 100644 --- a/src/bhyve/bhyve_command.c +++ b/src/bhyve/bhyve_command.c @@ -173,7 +173,6 @@ bhyveBuildNetArgStr(const virDomainDef *def, virCommandPtr cmd) return -1; } - virCommandAddArgList(cmd, "-s", "0:0,hostbridge", NULL); virCommandAddArg(cmd, "-s"); virCommandAddArgFormat(cmd, "1:0,virtio-net,%s", realifname); @@ -300,6 +299,7 @@ virBhyveProcessBuildBhyveCmd(bhyveConnPtr driver ATTRIBUTE_UNUSED, virCommandAddArg(cmd, "-H"); /* vmexit from guest on hlt */ virCommandAddArg(cmd, "-P"); /* vmexit from guest on pause */ + virCommandAddArgList(cmd, "-s", "0:0,hostbridge", NULL); /* Devices */ if (bhyveBuildNetArgStr(vm->def, cmd) < 0) goto error; -- 1.8.4.2

On Sat, Mar 15, 2014 at 07:27:35PM +0400, Roman Bogorodskiy wrote:
Addition of the hostbridge device was mistakenly placed to bhyveBuildNetArgStr(). This could result in hostbridge device not being added to the commandline if there are no network devices specified, but hostbridge device should be added unconditionally.
Fix by placing it to virBhyveProcessBuildBhyveCmd(). --- src/bhyve/bhyve_command.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c index 2ec97fc..9fc68ae 100644 --- a/src/bhyve/bhyve_command.c +++ b/src/bhyve/bhyve_command.c @@ -173,7 +173,6 @@ bhyveBuildNetArgStr(const virDomainDef *def, virCommandPtr cmd) return -1; }
- virCommandAddArgList(cmd, "-s", "0:0,hostbridge", NULL); virCommandAddArg(cmd, "-s"); virCommandAddArgFormat(cmd, "1:0,virtio-net,%s", realifname);
@@ -300,6 +299,7 @@ virBhyveProcessBuildBhyveCmd(bhyveConnPtr driver ATTRIBUTE_UNUSED, virCommandAddArg(cmd, "-H"); /* vmexit from guest on hlt */ virCommandAddArg(cmd, "-P"); /* vmexit from guest on pause */
+ virCommandAddArgList(cmd, "-s", "0:0,hostbridge", NULL); /* Devices */ if (bhyveBuildNetArgStr(vm->def, cmd) < 0) goto error;
ACK, though I think this rather suggests it is time to create a unit test todo xml -> argv conversion, eg copy idea of qemuxml2argvtest.c Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

Daniel P. Berrange wrote:
On Sat, Mar 15, 2014 at 07:27:35PM +0400, Roman Bogorodskiy wrote:
Addition of the hostbridge device was mistakenly placed to bhyveBuildNetArgStr(). This could result in hostbridge device not being added to the commandline if there are no network devices specified, but hostbridge device should be added unconditionally.
Fix by placing it to virBhyveProcessBuildBhyveCmd(). --- src/bhyve/bhyve_command.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c index 2ec97fc..9fc68ae 100644 --- a/src/bhyve/bhyve_command.c +++ b/src/bhyve/bhyve_command.c @@ -173,7 +173,6 @@ bhyveBuildNetArgStr(const virDomainDef *def, virCommandPtr cmd) return -1; }
- virCommandAddArgList(cmd, "-s", "0:0,hostbridge", NULL); virCommandAddArg(cmd, "-s"); virCommandAddArgFormat(cmd, "1:0,virtio-net,%s", realifname);
@@ -300,6 +299,7 @@ virBhyveProcessBuildBhyveCmd(bhyveConnPtr driver ATTRIBUTE_UNUSED, virCommandAddArg(cmd, "-H"); /* vmexit from guest on hlt */ virCommandAddArg(cmd, "-P"); /* vmexit from guest on pause */
+ virCommandAddArgList(cmd, "-s", "0:0,hostbridge", NULL); /* Devices */ if (bhyveBuildNetArgStr(vm->def, cmd) < 0) goto error;
ACK, though I think this rather suggests it is time to create a unit test todo xml -> argv conversion, eg copy idea of qemuxml2argvtest.c
Pushed, thanks! Added a unit test for that to my todo list. Roman Bogorodskiy

On Sat, Mar 15, 2014 at 07:27:34PM +0400, Roman Bogorodskiy wrote:
--- src/bhyve/bhyve_command.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
ACK Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
participants (2)
-
Daniel P. Berrange
-
Roman Bogorodskiy