[libvirt] [PATCH 0/3] bhyve: allow locking memory

This patch series adds support for locking guest memory to the bhyve driver using the following elements <memoryBacking> <locked/> </memoryBacking> When specified, the -S flag is passed to the bhyve binary. Fabian Freyer (3): bhyve: add support for wiring memory bhyve: add tests for wiring memory bhyve: document support for wiring guest memory docs/drvbhyve.html.in | 14 +++++++++ docs/news.xml | 10 ++++++ src/bhyve/bhyve_command.c | 3 ++ src/bhyve/bhyve_parse_command.c | 3 ++ tests/bhyveargv2xmldata/bhyveargv2xml-wired.args | 7 +++++ tests/bhyveargv2xmldata/bhyveargv2xml-wired.xml | 19 ++++++++++++ tests/bhyveargv2xmltest.c | 1 + tests/bhyvexml2argvdata/bhyvexml2argv-wired.args | 10 ++++++ tests/bhyvexml2argvdata/bhyvexml2argv-wired.ldargs | 3 ++ tests/bhyvexml2argvdata/bhyvexml2argv-wired.xml | 26 ++++++++++++++++ tests/bhyvexml2argvtest.c | 1 + .../bhyvexml2xmloutdata/bhyvexml2xmlout-wired.xml | 36 ++++++++++++++++++++++ tests/bhyvexml2xmltest.c | 1 + 13 files changed, 134 insertions(+) create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-wired.args create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-wired.xml create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-wired.args create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-wired.ldargs create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-wired.xml create mode 100644 tests/bhyvexml2xmloutdata/bhyvexml2xmlout-wired.xml -- 2.15.1

The <memoryBacking><locked/></memoryBacking> element will now pass the wired (-S) flag to the bhyve command. --- src/bhyve/bhyve_command.c | 3 +++ src/bhyve/bhyve_parse_command.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c index 9413ae5c1..e3f7ded7d 100644 --- a/src/bhyve/bhyve_command.c +++ b/src/bhyve/bhyve_command.c @@ -474,6 +474,9 @@ virBhyveProcessBuildBhyveCmd(virConnectPtr conn, virCommandAddArgFormat(cmd, "%llu", VIR_DIV_UP(virDomainDefGetMemoryInitial(def), 1024)); + if (def->mem.locked) + virCommandAddArg(cmd, "-S"); /* Wire guest memory */ + /* Options */ if (def->features[VIR_DOMAIN_FEATURE_ACPI] == VIR_TRISTATE_SWITCH_ON) virCommandAddArg(cmd, "-A"); /* Create an ACPI table */ diff --git a/src/bhyve/bhyve_parse_command.c b/src/bhyve/bhyve_parse_command.c index fcaaed275..27916c528 100644 --- a/src/bhyve/bhyve_parse_command.c +++ b/src/bhyve/bhyve_parse_command.c @@ -721,6 +721,9 @@ bhyveParseBhyveCommandLine(virDomainDefPtr def, goto error; } break; + case 'S': + def->mem.locked = true; + break; } } -- 2.15.1

--- tests/bhyveargv2xmldata/bhyveargv2xml-wired.args | 7 +++++ tests/bhyveargv2xmldata/bhyveargv2xml-wired.xml | 19 ++++++++++++ tests/bhyveargv2xmltest.c | 1 + tests/bhyvexml2argvdata/bhyvexml2argv-wired.args | 10 ++++++ tests/bhyvexml2argvdata/bhyvexml2argv-wired.ldargs | 3 ++ tests/bhyvexml2argvdata/bhyvexml2argv-wired.xml | 26 ++++++++++++++++ tests/bhyvexml2argvtest.c | 1 + .../bhyvexml2xmloutdata/bhyvexml2xmlout-wired.xml | 36 ++++++++++++++++++++++ tests/bhyvexml2xmltest.c | 1 + 9 files changed, 104 insertions(+) create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-wired.args create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-wired.xml create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-wired.args create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-wired.ldargs create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-wired.xml create mode 100644 tests/bhyvexml2xmloutdata/bhyvexml2xmlout-wired.xml diff --git a/tests/bhyveargv2xmldata/bhyveargv2xml-wired.args b/tests/bhyveargv2xmldata/bhyveargv2xml-wired.args new file mode 100644 index 000000000..5d0ad765b --- /dev/null +++ b/tests/bhyveargv2xmldata/bhyveargv2xml-wired.args @@ -0,0 +1,7 @@ +/usr/sbin/bhyve \ +-c 1 \ +-m 214 \ +-H \ +-P \ +-S \ +-s 0:0,hostbridge bhyve diff --git a/tests/bhyveargv2xmldata/bhyveargv2xml-wired.xml b/tests/bhyveargv2xmldata/bhyveargv2xml-wired.xml new file mode 100644 index 000000000..0f4cea544 --- /dev/null +++ b/tests/bhyveargv2xmldata/bhyveargv2xml-wired.xml @@ -0,0 +1,19 @@ +<domain type='bhyve'> + <name>bhyve</name> + <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid> + <memory unit='KiB'>219136</memory> + <currentMemory unit='KiB'>219136</currentMemory> + <memoryBacking> + <locked/> + </memoryBacking> + <vcpu placement='static'>1</vcpu> + <os> + <type>hvm</type> + </os> + <clock offset='localtime'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>destroy</on_reboot> + <on_crash>destroy</on_crash> + <devices> + </devices> +</domain> diff --git a/tests/bhyveargv2xmltest.c b/tests/bhyveargv2xmltest.c index e5d78530c..d55236484 100644 --- a/tests/bhyveargv2xmltest.c +++ b/tests/bhyveargv2xmltest.c @@ -163,6 +163,7 @@ mymain(void) driver.bhyvecaps = BHYVE_CAP_RTC_UTC; DO_TEST("base"); + DO_TEST("wired"); DO_TEST("oneline"); DO_TEST("name"); DO_TEST("console"); diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-wired.args b/tests/bhyvexml2argvdata/bhyvexml2argv-wired.args new file mode 100644 index 000000000..13d4f4909 --- /dev/null +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-wired.args @@ -0,0 +1,10 @@ +/usr/sbin/bhyve \ +-c 1 \ +-m 214 \ +-S \ +-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-wired.ldargs b/tests/bhyvexml2argvdata/bhyvexml2argv-wired.ldargs new file mode 100644 index 000000000..32538b558 --- /dev/null +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-wired.ldargs @@ -0,0 +1,3 @@ +/usr/sbin/bhyveload \ +-m 214 \ +-d /tmp/freebsd.img bhyve diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-wired.xml b/tests/bhyvexml2argvdata/bhyvexml2argv-wired.xml new file mode 100644 index 000000000..639e047dd --- /dev/null +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-wired.xml @@ -0,0 +1,26 @@ +<domain type='bhyve'> + <name>bhyve</name> + <uuid>df3be7e7-a104-11e3-aeb0-50e5492bd3dc</uuid> + <memory>219136</memory> + <memoryBacking> + <locked/> + </memoryBacking> + <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'/> + <address type='drive' controller='0' bus='0' target='2' unit='0'/> + </disk> + <interface type='bridge'> + <mac address='52:54:00:b9:94:02'/> + <model type='virtio'/> + <source bridge="virbr0"/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> + </interface> + </devices> +</domain> diff --git a/tests/bhyvexml2argvtest.c b/tests/bhyvexml2argvtest.c index 6f3b0c2eb..b08b1675f 100644 --- a/tests/bhyvexml2argvtest.c +++ b/tests/bhyvexml2argvtest.c @@ -179,6 +179,7 @@ mymain(void) BHYVE_CAP_FBUF | BHYVE_CAP_XHCI; DO_TEST("base"); + DO_TEST("wired"); DO_TEST("acpiapic"); DO_TEST("disk-cdrom"); DO_TEST("disk-virtio"); diff --git a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-wired.xml b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-wired.xml new file mode 100644 index 000000000..ed564e277 --- /dev/null +++ b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-wired.xml @@ -0,0 +1,36 @@ +<domain type='bhyve'> + <name>bhyve</name> + <uuid>df3be7e7-a104-11e3-aeb0-50e5492bd3dc</uuid> + <memory unit='KiB'>219136</memory> + <currentMemory unit='KiB'>219136</currentMemory> + <memoryBacking> + <locked/> + </memoryBacking> + <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='2' 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 4d9c1681d..6aaeab741 100644 --- a/tests/bhyvexml2xmltest.c +++ b/tests/bhyvexml2xmltest.c @@ -84,6 +84,7 @@ mymain(void) DO_TEST_DIFFERENT("acpiapic"); DO_TEST_DIFFERENT("base"); + DO_TEST_DIFFERENT("wired"); DO_TEST_DIFFERENT("bhyveload-bootorder"); DO_TEST_DIFFERENT("bhyveload-bootorder1"); DO_TEST_DIFFERENT("bhyveload-bootorder2"); -- 2.15.1

--- docs/drvbhyve.html.in | 14 ++++++++++++++ docs/news.xml | 10 ++++++++++ 2 files changed, 24 insertions(+) diff --git a/docs/drvbhyve.html.in b/docs/drvbhyve.html.in index bde8298a5..5b5513d3d 100644 --- a/docs/drvbhyve.html.in +++ b/docs/drvbhyve.html.in @@ -430,6 +430,20 @@ supports Intel e1000 network adapter emulation. It's supported in libvirt <model type='<b>e1000</b>'/> </interface> ... +</pre> + +<h3><a id="wired">Wiring guest memory</a></h3> + +<p><span class="since">Since 4.4.0</span>, it's possible to specify that guest memory should +be wired and cannot be swapped out as follows:</p> +<pre> +<domain type="bhyve"> + ... + <memoryBacking> + <locked/> + </memoryBacking> + ... +</domain> </pre> </body> diff --git a/docs/news.xml b/docs/news.xml index 80181415c..5b7dd4c4a 100644 --- a/docs/news.xml +++ b/docs/news.xml @@ -35,6 +35,16 @@ <libvirt> <release version="v4.4.0" date="unreleased"> <section title="New features"> + <change> + <summary> + bhyve: Support locking guest memory + </summary> + <description> + Bhyve's guest memory may be wired using the + <code><memoryBacking><locked/></memoryBacking></code> + element. + </description> + </change> </section> <section title="Improvements"> </section> -- 2.15.1

Fabian Freyer wrote:
This patch series adds support for locking guest memory to the bhyve driver using the following elements
<memoryBacking> <locked/> </memoryBacking>
When specified, the -S flag is passed to the bhyve binary.
Fabian Freyer (3): bhyve: add support for wiring memory bhyve: add tests for wiring memory bhyve: document support for wiring guest memory
docs/drvbhyve.html.in | 14 +++++++++ docs/news.xml | 10 ++++++ src/bhyve/bhyve_command.c | 3 ++ src/bhyve/bhyve_parse_command.c | 3 ++ tests/bhyveargv2xmldata/bhyveargv2xml-wired.args | 7 +++++ tests/bhyveargv2xmldata/bhyveargv2xml-wired.xml | 19 ++++++++++++ tests/bhyveargv2xmltest.c | 1 + tests/bhyvexml2argvdata/bhyvexml2argv-wired.args | 10 ++++++ tests/bhyvexml2argvdata/bhyvexml2argv-wired.ldargs | 3 ++ tests/bhyvexml2argvdata/bhyvexml2argv-wired.xml | 26 ++++++++++++++++ tests/bhyvexml2argvtest.c | 1 + .../bhyvexml2xmloutdata/bhyvexml2xmlout-wired.xml | 36 ++++++++++++++++++++++ tests/bhyvexml2xmltest.c | 1 + 13 files changed, 134 insertions(+) create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-wired.args create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-wired.xml create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-wired.args create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-wired.ldargs create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-wired.xml create mode 100644 tests/bhyvexml2xmloutdata/bhyvexml2xmlout-wired.xml
Thanks for the patches, I've pushed the series with some syntax-check fixes (trailing whitespaces, tabs instead of whitespaces) and added 'Signed-off-by' line which is mandatory now. Roman Bogorodskiy

On Sun, May 13, 2018 at 14:01:25 +0400, Roman Bogorodskiy wrote:
Fabian Freyer wrote:
[...]
13 files changed, 134 insertions(+) create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-wired.args create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-wired.xml create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-wired.args create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-wired.ldargs create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-wired.xml create mode 100644 tests/bhyvexml2xmloutdata/bhyvexml2xmlout-wired.xml
Thanks for the patches, I've pushed the series with some syntax-check fixes (trailing whitespaces, tabs instead of whitespaces) and added 'Signed-off-by' line which is mandatory now.
Note that 'Signed-off-by' should _NOT_ be added without explicit consent of the author of the patches. Otherwise it defeats the purpose of certification that the author agrees and complies with the Developer certificate of origin. Adding it without explicit consent makes the Signed-off-by line just a useless piece of jewelery added to appease the push hook.
Roman Bogorodskiy
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list

Peter Krempa wrote:
On Sun, May 13, 2018 at 14:01:25 +0400, Roman Bogorodskiy wrote:
Fabian Freyer wrote:
[...]
13 files changed, 134 insertions(+) create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-wired.args create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-wired.xml create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-wired.args create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-wired.ldargs create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-wired.xml create mode 100644 tests/bhyvexml2xmloutdata/bhyvexml2xmlout-wired.xml
Thanks for the patches, I've pushed the series with some syntax-check fixes (trailing whitespaces, tabs instead of whitespaces) and added 'Signed-off-by' line which is mandatory now.
Note that 'Signed-off-by' should _NOT_ be added without explicit consent of the author of the patches. Otherwise it defeats the purpose of certification that the author agrees and complies with the Developer certificate of origin. Adding it without explicit consent makes the Signed-off-by line just a useless piece of jewelery added to appease the push hook.
Oh, sorry about that. I assumed as Fabian is a long time contributor, he's familiar with the general project policies. Fabian, do you have any issue with that?
Roman Bogorodskiy
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Roman Bogorodskiy

On 14 May 2018, at 8:51, Roman Bogorodskiy wrote:
Peter Krempa wrote:
On Sun, May 13, 2018 at 14:01:25 +0400, Roman Bogorodskiy wrote:
Fabian Freyer wrote:
[...]
13 files changed, 134 insertions(+) create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-wired.args create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-wired.xml create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-wired.args create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-wired.ldargs create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-wired.xml create mode 100644 tests/bhyvexml2xmloutdata/bhyvexml2xmlout-wired.xml
Thanks for the patches, I've pushed the series with some syntax-check fixes (trailing whitespaces, tabs instead of whitespaces) and added 'Signed-off-by' line which is mandatory now.
Note that 'Signed-off-by' should _NOT_ be added without explicit consent of the author of the patches. Otherwise it defeats the purpose of certification that the author agrees and complies with the Developer certificate of origin. Adding it without explicit consent makes the Signed-off-by line just a useless piece of jewelery added to appease the push hook.
Oh, sorry about that. I assumed as Fabian is a long time contributor, he's familiar with the general project policies.
Fabian, do you have any issue with that? All good with me.
In case you need it from me, for the whole series: Signed-off-by: Fabian Freyer <fabian.freyer@physik.tu-berlin.de>
participants (3)
-
Fabian Freyer
-
Peter Krempa
-
Roman Bogorodskiy