Re: [libvirt] [PATCH] bhyve: fix virtio disk addresses

2017-02-07 Thread Roman Bogorodskiy
  Andrea Bolognani wrote:

> On Wed, 2017-02-01 at 20:25 +0400, Roman Bogorodskiy wrote:
> > Like it usually happens, I fixed one thing and broke another:
> > in 803966c76 address allocation was fixed for SATA disks, but
> > broke that for virtio disks, because it dropped disk address
> > assignment completely. It's not needed for SATA disks anymore,
> > but still needed for the virtio ones.
> > 
> > Bring that back and add a couple of tests to make sure it won't
> > happen again.
> 
> I didn't actually test this[1], but both the code and the
> tests look reasonable enough, plus 'make check' and 'make
> syntax-check' are all green[2] on FreeBSD, so:
> 
> ACK

Pushed, thanks!

> [1] Can you run bhyve guests inside a FreeBSD KVM guest?

I guess that generally you cannot because it requires hardware
virtualization support (i.e. POPCNT CPU feature and maybe something
else). Probably it's possible with KVM's nested virtualization, I've
been wanting to check that for a while but somehow always forget about
that when I have time.

> [2] Well, mostly. We really should fix qemuxml2argvtest once
> and for all, and it looks like we're sooo close now!

True.

Roman Bogorodskiy


signature.asc
Description: PGP signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH] bhyve: fix virtio disk addresses

2017-02-07 Thread Andrea Bolognani
On Wed, 2017-02-01 at 20:25 +0400, Roman Bogorodskiy wrote:
> Like it usually happens, I fixed one thing and broke another:
> in 803966c76 address allocation was fixed for SATA disks, but
> broke that for virtio disks, because it dropped disk address
> assignment completely. It's not needed for SATA disks anymore,
> but still needed for the virtio ones.
> 
> Bring that back and add a couple of tests to make sure it won't
> happen again.

I didn't actually test this[1], but both the code and the
tests look reasonable enough, plus 'make check' and 'make
syntax-check' are all green[2] on FreeBSD, so:

ACK


[1] Can you run bhyve guests inside a FreeBSD KVM guest?
[2] Well, mostly. We really should fix qemuxml2argvtest once
and for all, and it looks like we're sooo close now!
-- 
Andrea Bolognani / Red Hat / Virtualization

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH] bhyve: fix virtio disk addresses

2017-02-01 Thread Roman Bogorodskiy
Like it usually happens, I fixed one thing and broke another:
in 803966c76 address allocation was fixed for SATA disks, but
broke that for virtio disks, because it dropped disk address
assignment completely. It's not needed for SATA disks anymore,
but still needed for the virtio ones.

Bring that back and add a couple of tests to make sure it won't
happen again.
---
 src/bhyve/bhyve_device.c   | 16 +
 .../bhyvexml2argv-addr-multiple-virtio-disks.args  | 11 ++
 ...bhyvexml2argv-addr-multiple-virtio-disks.ldargs |  3 ++
 .../bhyvexml2argv-addr-multiple-virtio-disks.xml   | 32 +
 .../bhyvexml2argv-addr-single-virtio-disk.args |  9 +
 .../bhyvexml2argv-addr-single-virtio-disk.ldargs   |  3 ++
 .../bhyvexml2argv-addr-single-virtio-disk.xml  | 22 
 tests/bhyvexml2argvtest.c  |  2 ++
 .../bhyvexml2xmlout-addr-multiple-virtio-disks.xml | 42 ++
 .../bhyvexml2xmlout-addr-single-virtio-disk.xml| 30 
 tests/bhyvexml2xmltest.c   |  2 ++
 11 files changed, 172 insertions(+)
 create mode 100644 
tests/bhyvexml2argvdata/bhyvexml2argv-addr-multiple-virtio-disks.args
 create mode 100644 
tests/bhyvexml2argvdata/bhyvexml2argv-addr-multiple-virtio-disks.ldargs
 create mode 100644 
tests/bhyvexml2argvdata/bhyvexml2argv-addr-multiple-virtio-disks.xml
 create mode 100644 
tests/bhyvexml2argvdata/bhyvexml2argv-addr-single-virtio-disk.args
 create mode 100644 
tests/bhyvexml2argvdata/bhyvexml2argv-addr-single-virtio-disk.ldargs
 create mode 100644 
tests/bhyvexml2argvdata/bhyvexml2argv-addr-single-virtio-disk.xml
 create mode 100644 
tests/bhyvexml2xmloutdata/bhyvexml2xmlout-addr-multiple-virtio-disks.xml
 create mode 100644 
tests/bhyvexml2xmloutdata/bhyvexml2xmlout-addr-single-virtio-disk.xml

diff --git a/src/bhyve/bhyve_device.c b/src/bhyve/bhyve_device.c
index 29528230f..55ce631ec 100644
--- a/src/bhyve/bhyve_device.c
+++ b/src/bhyve/bhyve_device.c
@@ -129,6 +129,22 @@ bhyveAssignDevicePCISlots(virDomainDefPtr def,
 goto error;
 }
 
+for (i = 0; i < def->ndisks; i++) {
+/* We only handle virtio disk addresses as SATA disks are
+ * attached to a controller and don't have their own PCI
+ * addresses */
+if (def->disks[i]->bus != VIR_DOMAIN_DISK_BUS_VIRTIO)
+continue;
+
+if (def->disks[i]->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI &&
+!virPCIDeviceAddressIsEmpty(>disks[i]->info.addr.pci))
+continue;
+if (virDomainPCIAddressReserveNextAddr(addrs, >disks[i]->info,
+   VIR_PCI_CONNECT_TYPE_PCI_DEVICE,
+   -1) < 0)
+goto error;
+}
+
 return 0;
 
  error:
diff --git 
a/tests/bhyvexml2argvdata/bhyvexml2argv-addr-multiple-virtio-disks.args 
b/tests/bhyvexml2argvdata/bhyvexml2argv-addr-multiple-virtio-disks.args
new file mode 100644
index 0..8cc166894
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-addr-multiple-virtio-disks.args
@@ -0,0 +1,11 @@
+/usr/sbin/bhyve \
+-c 1 \
+-m 214 \
+-u \
+-H \
+-P \
+-s 0:0,hostbridge \
+-s 3:0,virtio-net,faketapdev,mac=52:54:00:bc:85:fe \
+-s 2:0,virtio-blk,/tmp/freebsd.img \
+-s 4:0,virtio-blk,/tmp/test.img \
+-s 5:0,virtio-blk,/tmp/test2.img bhyve
diff --git 
a/tests/bhyvexml2argvdata/bhyvexml2argv-addr-multiple-virtio-disks.ldargs 
b/tests/bhyvexml2argvdata/bhyvexml2argv-addr-multiple-virtio-disks.ldargs
new file mode 100644
index 0..32538b558
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-addr-multiple-virtio-disks.ldargs
@@ -0,0 +1,3 @@
+/usr/sbin/bhyveload \
+-m 214 \
+-d /tmp/freebsd.img bhyve
diff --git 
a/tests/bhyvexml2argvdata/bhyvexml2argv-addr-multiple-virtio-disks.xml 
b/tests/bhyvexml2argvdata/bhyvexml2argv-addr-multiple-virtio-disks.xml
new file mode 100644
index 0..9bcd0a629
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-addr-multiple-virtio-disks.xml
@@ -0,0 +1,32 @@
+
+  bhyve
+  df3be7e7-a104-11e3-aeb0-50e5492bd3dc
+  219136
+  1
+  
+hvm
+  
+  
+
+  
+  
+  
+
+
+  
+  
+  
+
+
+  
+  
+  
+
+
+  
+  
+  
+  
+
+  
+
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-addr-single-virtio-disk.args 
b/tests/bhyvexml2argvdata/bhyvexml2argv-addr-single-virtio-disk.args
new file mode 100644
index 0..4dcc40404
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-addr-single-virtio-disk.args
@@ -0,0 +1,9 @@
+/usr/sbin/bhyve \
+-c 1 \
+-m 214 \
+-u \
+-H \
+-P \
+-s 0:0,hostbridge \
+-s 3:0,virtio-net,faketapdev,mac=52:54:00:bc:85:fe \
+-s 2:0,virtio-blk,/tmp/freebsd.img bhyve
diff --git 
a/tests/bhyvexml2argvdata/bhyvexml2argv-addr-single-virtio-disk.ldargs 
b/tests/bhyvexml2argvdata/bhyvexml2argv-addr-single-virtio-disk.ldargs
new file mode 100644
index