[libvirt] [PATCH v6 0/9] x86: Secure Encrypted Virtualization (AMD)
by Brijesh Singh
This patch series provides support for launching an encrypted guest using
AMD's new Secure Encrypted Virtualization (SEV) feature.
SEV is an extension to the AMD-V architecture which supports running
multiple VMs under the control of a hypervisor. When enabled, SEV feature
allows the memory contents of a virtual machine (VM) to be transparently
encrypted with a key unique to the guest VM.
At very high level the flow looks this:
1. mgmt tool calls virConnectGetDomainCapabilities. This returns an XML document
that includes the following
<feature>
...
<sev supported='yes'>
<cbitpos> </cbitpos>
<reduced-phys-bits> </reduced-phys-bits>
<pdh> </pdh>
<cert-chain> </cert-chain>
</feature>
If <sev> is provided then we indicate that hypervisor is capable of launching
SEV guest.
2. (optional) mgmt tool can provide the PDH and Cert-chain to guest owner in case
if guest owner wish to establish a secure connection with SEV firmware to
negotiate a key used for validating the measurement.
3. mgmt tool requests to start a guest calling virCreateXML(), passing VIR_DOMAIN_START_PAUSED.
The xml would include
<launch-security type='sev'>
<cbitpos> </cbitpos> /* the value is same as what is obtained via virConnectGetDomainCapabilities()
<reduced-phys-bits> </reduced-phys-bits> /* the value is same as what is obtained via virConnectGetDomainCapabilities()
<dh-cert> .. </dh> /* guest owners diffie-hellman key */ (optional)
<session> ..</session> /* guest owners session blob */ (optional)
<policy> ..</policy> /* guest policy */ (optional)
</launch-security>
4. Libvirt generate the QEMU cli arg to enable the SEV feature, a typical
args looks like this:
# $QEMU ..
-machine memory-encryption=sev0 \
-object sev-guest,id=sev0,dh-cert-file=<file>....
5. Libvirt generates lifecycle VIR_DOMAIN_EVENT_SUSPENDED_PAUSED event
6. mgmt tool gets the VIR_DOMAIN_EVENT_SUSPENDED_PAUSED and calls virDomainGetLaunchSecretInfo()
to retrieve the measurement of encrypted memory.
7. (optional) mgmt tool can provide the measurement value to guest owner, which can
validate the measurement and gives GO/NO-GO answer. If mgmt tool gets GO then
it resumes the guest otherwise it calls destroy() to kill the guest.
8. mgmt tool resumes the guest
TODO:
* SEV guest require to use DMA apis for the virtio devices. In order to use the DMA
apis the virtio devices must have this tag
<driver iommu=on ats=on>
It is a bit unclear to me where these changes need to go. Do we need to
modify the libvirt to automatically add these when SEV is enabled or
we ask mgmt tool to make sure that it creates XML with right tag to enable
the DMA APIs for virtio devices. I am looking for some suggestions.
Using these patches we have succesfully booted and tested a guest both with and
without SEV enabled.
SEV Firmware API spec is available at:
https://support.amd.com/TechDocs/55766_SEV-KM%20API_Specification.pdf
Change since v5:
* drop the seperate test patch and merge the code with other patches.
* rename the xml from sev -> launch-security-sev
* make policy field mandatory
* address multiple feedback from previous reviews.
Changes since v4:
* add /dev/sev in shared device list
Changes since v3:
* rename QEMU_CAPS_SEV -> QEMU_CAPS_SEV_GUEST
* update caps_2.12.0.x86_64.replies to include query-sev-capabilities data
Changes since v2:
* make cbitpos, policy and reduced-phys-bits as unsigned int
* update virDomainGetLaunchSecurityInfo to accept virTypedParameterPtr *params
instead of virTypedParameterPtr params.
Changes since v1:
* rename <sev> -> <launch-security> for domain
* add more information about policy and other fields in domaincaps.html
* split the domain_conf support in two patches
* add virDomainGetLaunchInfo() to retrieve the SEV measurement
* extend virsh command to show the domain's launch security information
* add test cases to validate newly added <launch-security> element
* fix issues reported with 'make check' and 'make syntax-check'
The complete git tree is available at:
https://github.com/codomania/libvirt/tree/v6
Brijesh Singh (9):
qemu: provide support to query the SEV capability
qemu: introduce SEV feature in hypervisor capabilities
conf: introduce launch-security element in domain
qemu/cgroup: add /dev/sev in shared devices list
qemu: add support to launch SEV guest
libvirt: add new public API to get launch security info
remote: implement the remote protocol for launch security
qemu: Add support to launch security info
virsh: implement new command for launch security
docs/drvqemu.html.in | 1 +
docs/formatdomain.html.in | 115 ++++++++++++++++++
docs/formatdomaincaps.html.in | 40 +++++++
docs/schemas/domaincaps.rng | 20 ++++
docs/schemas/domaincommon.rng | 39 ++++++
include/libvirt/libvirt-domain.h | 17 +++
src/conf/domain_capabilities.c | 20 ++++
src/conf/domain_capabilities.h | 14 +++
src/conf/domain_conf.c | 133 +++++++++++++++++++++
src/conf/domain_conf.h | 27 +++++
src/driver-hypervisor.h | 7 ++
src/libvirt-domain.c | 48 ++++++++
src/libvirt_public.syms | 5 +
src/qemu/qemu.conf | 2 +-
src/qemu/qemu_capabilities.c | 49 ++++++++
src/qemu/qemu_capabilities.h | 4 +
src/qemu/qemu_capspriv.h | 4 +
src/qemu/qemu_cgroup.c | 2 +-
src/qemu/qemu_command.c | 41 +++++++
src/qemu/qemu_driver.c | 68 +++++++++++
src/qemu/qemu_monitor.c | 17 +++
src/qemu/qemu_monitor.h | 6 +
src/qemu/qemu_monitor_json.c | 116 ++++++++++++++++++
src/qemu/qemu_monitor_json.h | 5 +
src/qemu/qemu_process.c | 62 ++++++++++
src/qemu/test_libvirtd_qemu.aug.in | 1 +
src/remote/remote_daemon_dispatch.c | 47 ++++++++
src/remote/remote_driver.c | 42 ++++++-
src/remote/remote_protocol.x | 20 +++-
src/remote_protocol-structs | 11 ++
tests/genericxml2xmlindata/launch-security-sev.xml | 24 ++++
tests/genericxml2xmltest.c | 2 +
.../caps_2.12.0.x86_64.replies | 10 ++
tests/qemucapabilitiesdata/caps_2.12.0.x86_64.xml | 3 +-
tests/qemuxml2argvdata/launch-security-sev.args | 29 +++++
tests/qemuxml2argvdata/launch-security-sev.xml | 37 ++++++
tests/qemuxml2argvtest.c | 4 +
tools/virsh-domain.c | 81 +++++++++++++
tools/virsh.pod | 5 +
39 files changed, 1173 insertions(+), 5 deletions(-)
create mode 100644 tests/genericxml2xmlindata/launch-security-sev.xml
create mode 100644 tests/qemuxml2argvdata/launch-security-sev.args
create mode 100644 tests/qemuxml2argvdata/launch-security-sev.xml
--
2.14.3
6 years, 6 months
[libvirt] [PATCH] virDomainDefCopy: Skip ostype checks
by Michal Privoznik
When parsing domain XML the virCapsDomainData lookup is performed
in order to fill in missing def->os.arch and def->os.machine
strings. Well, when doing copy of already existing virDomainDef
we don't want any automagic fill in of defaults (and those two
strings are going to be provided at this point anyway by first
parse of the domain XML).
What is even worse is that we do not look up capabilities for
parsed emulator path rather than some generic capabilities for
parsed arch. Therefore, if emulator points to qemu under
non-default path (say $HOME/qemu-system-arm) but there's no such
qemu under the default path (say /usr/bin/qemu-system-arm) the
capabilities lookup fails and creating the copy is denied.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/conf/domain_conf.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 86814d5f64..f36a1bfe79 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -28397,7 +28397,8 @@ virDomainDefCopy(virDomainDefPtr src,
virDomainDefPtr ret;
unsigned int format_flags = VIR_DOMAIN_DEF_FORMAT_SECURE;
unsigned int parse_flags = VIR_DOMAIN_DEF_PARSE_INACTIVE |
- VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE;
+ VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE |
+ VIR_DOMAIN_DEF_PARSE_SKIP_OSTYPE_CHECKS;
if (migratable)
format_flags |= VIR_DOMAIN_DEF_FORMAT_INACTIVE | VIR_DOMAIN_DEF_FORMAT_MIGRATABLE;
--
2.16.4
6 years, 6 months
[libvirt] [PATCH] tests: qemuxml2argv: Make tests based on DO_TEST_CAPS_INTERNAL stable
by Peter Krempa
To avoid problems with test cases specifying an alias machine type which
would change once capabilities for a newer version are added strip all
alias machine types for the DO_TEST_CAPS_INTERNAL based tests.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/qemu/qemu_capabilities.c | 17 +++++++++++++++++
src/qemu/qemu_capspriv.h | 3 +++
.../disk-virtio-scsi-reservations.x86_64-latest.args | 2 +-
tests/qemuxml2argvdata/genid-auto.x86_64-latest.args | 2 +-
tests/qemuxml2argvdata/genid.x86_64-latest.args | 2 +-
tests/qemuxml2argvtest.c | 1 +
6 files changed, 24 insertions(+), 3 deletions(-)
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index b8764eacd8..a4a89cedfd 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -5156,3 +5156,20 @@ virQEMUCapsSetMicrocodeVersion(virQEMUCapsPtr qemuCaps,
{
qemuCaps->microcodeVersion = microcodeVersion;
}
+
+
+/**
+ * virQEMUCapsStripMachineAliases:
+ * @qemuCaps: capabilities object to process
+ *
+ * Remove all aliases so that the tests depending on the latest capabilities
+ * file can be stable when new files are added.
+ */
+void
+virQEMUCapsStripMachineAliases(virQEMUCapsPtr qemuCaps)
+{
+ size_t i;
+
+ for (i = 0; i < qemuCaps->nmachineTypes; i++)
+ VIR_FREE(qemuCaps->machineTypes[i].alias);
+}
diff --git a/src/qemu/qemu_capspriv.h b/src/qemu/qemu_capspriv.h
index fea039ef3a..021260de2f 100644
--- a/src/qemu/qemu_capspriv.h
+++ b/src/qemu/qemu_capspriv.h
@@ -97,4 +97,7 @@ virQEMUCapsProbeQMPCPUDefinitions(virQEMUCapsPtr qemuCaps,
void
virQEMUCapsSetMicrocodeVersion(virQEMUCapsPtr qemuCaps,
unsigned int microcodeVersion);
+
+void
+virQEMUCapsStripMachineAliases(virQEMUCapsPtr qemuCaps);
#endif
diff --git a/tests/qemuxml2argvdata/disk-virtio-scsi-reservations.x86_64-latest.args b/tests/qemuxml2argvdata/disk-virtio-scsi-reservations.x86_64-latest.args
index 768bc22f9f..927173fa03 100644
--- a/tests/qemuxml2argvdata/disk-virtio-scsi-reservations.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/disk-virtio-scsi-reservations.x86_64-latest.args
@@ -13,7 +13,7 @@ file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
path=/tmp/lib/domain--1-QEMUGuest1/pr-helper0.sock \
-object pr-manager-helper,id=pr-helper-scsi0-0-0-1,\
path=/path/to/qemu-pr-helper.sock \
--machine pc-i440fx-2.12,accel=tcg,usb=off,dump-guest-core=off \
+-machine pc,accel=tcg,usb=off,dump-guest-core=off \
-m 214 \
-realtime mlock=off \
-smp 8,sockets=8,cores=1,threads=1 \
diff --git a/tests/qemuxml2argvdata/genid-auto.x86_64-latest.args b/tests/qemuxml2argvdata/genid-auto.x86_64-latest.args
index ce163020b9..7412651479 100644
--- a/tests/qemuxml2argvdata/genid-auto.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/genid-auto.x86_64-latest.args
@@ -9,7 +9,7 @@ QEMU_AUDIO_DRV=none \
-S \
-object secret,id=masterKey0,format=raw,\
file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
--machine pc-i440fx-2.12,accel=tcg,usb=off,dump-guest-core=off \
+-machine pc,accel=tcg,usb=off,dump-guest-core=off \
-m 214 \
-realtime mlock=off \
-smp 1,sockets=1,cores=1,threads=1 \
diff --git a/tests/qemuxml2argvdata/genid.x86_64-latest.args b/tests/qemuxml2argvdata/genid.x86_64-latest.args
index 54e00f4bdb..dbffa7e1d2 100644
--- a/tests/qemuxml2argvdata/genid.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/genid.x86_64-latest.args
@@ -9,7 +9,7 @@ QEMU_AUDIO_DRV=none \
-S \
-object secret,id=masterKey0,format=raw,\
file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
--machine pc-i440fx-2.12,accel=tcg,usb=off,dump-guest-core=off \
+-machine pc,accel=tcg,usb=off,dump-guest-core=off \
-m 214 \
-realtime mlock=off \
-smp 1,sockets=1,cores=1,threads=1 \
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 61c7ae59aa..ab7a50817a 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -705,6 +705,7 @@ mymain(void)
if (!(info.qemuCaps = qemuTestParseCapabilitiesArch(virArchFromString(arch), \
capsfile))) \
return EXIT_FAILURE; \
+ virQEMUCapsStripMachineAliases(info.qemuCaps); \
if (virTestRun("QEMU XML-2-ARGV " name "." suffix, \
testCompareXMLToArgv, &info) < 0) \
ret = -1; \
--
2.16.2
6 years, 6 months
[libvirt] [PATCH] docs: Use proper article in formatdomain.html.in
by Martin Kletzander
It's "a hard_limit", not "an hard_limit". Probably that was just a typo.
Signed-off-by: Martin Kletzander <mkletzan(a)redhat.com>
---
Pushed as trivial.
I was *so* tempted to write "Fix an typo in a article...". I'm glad I was
because that made me triple check the commit message. Otherwise I would have a
typo like that somewhere there.
docs/formatdomain.html.in | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 8bb6636ea9f9..22ef81052d6b 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -1085,7 +1085,7 @@
of memory, which means a malicious guest allocating large amounts of
locked memory could cause a denial-of-service attack on the host.
Because of this, using this option is discouraged unless your workload
- demands it; even then, it's highly recommended to set an
+ demands it; even then, it's highly recommended to set a
<code>hard_limit</code> (see
<a href="#elementsMemoryTuning">memory tuning</a>) on memory allocation
suitable for the specific environment at the same time to mitigate
--
2.17.1
6 years, 6 months
[libvirt] [dbus PATCH] gdbus: Don't report libvirt errors for GetAll method on properties
by Pavel Hrdina
According to D-Bus specification if some property is not accessible
it may be omitted in the returned list of properties. However, such
error needs to be reported for Get method on that property.
In libvirt-dbus this can happen for Domain.SchedulerType property
for QEMU session connection.
Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
---
src/gdbus.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/src/gdbus.c b/src/gdbus.c
index 2cce6ff..4e35477 100644
--- a/src/gdbus.c
+++ b/src/gdbus.c
@@ -163,20 +163,19 @@ virtDBusGDBusHandlePropertyGetAll(GDBusMethodInvocation *invocation,
{
GVariant *value;
g_auto(GVariantBuilder) builder;
- g_autoptr(GError) error = NULL;
g_variant_builder_init(&builder, G_VARIANT_TYPE("(a{sv})"));
g_variant_builder_open(&builder, G_VARIANT_TYPE("a{sv}"));
for (gint i = 0; data->properties[i].name; i++) {
+ g_autoptr(GError) error = NULL;
+
data->properties[i].getFunc(objectPath, data->userData,
&value, &error);
- if (error) {
- g_dbus_method_invocation_return_gerror(invocation, error);
- return;
- }
+ if (error)
+ continue;
g_return_if_fail(value);
--
2.17.1
6 years, 6 months
[libvirt] [PATCH 0/9] qemu: Refactor and simplify handling of disk hotplug and commandline
by Peter Krempa
This refactor unifies setup of data for disk hotplug and command line
generation.
This applies on top of
'qemu: Handle managed persisten reservations separately'
as that applies on top of the staging branch for my ACKed refactors
which moved now, you can fetch everything at:
git fetch git://pipo.sk/pipo/libvirt.git disk-hotplug-refactor
Peter Krempa (9):
qemu: hotplug: Remove qemuDomainDelDiskSrcTLSObject
qemu: alias: Rename qemuAliasFromDisk to qemuAliasDiskDriveFromDisk
qemu: Reuse qemuBlockStorageSourceAttachApply in disk hotplug
qemu: hotplug: Extract hotplug of PR into
qemuBlockStorageSourceAttachApply
qemu: hotplug: Extract hotplug of secrets into
qemuBlockStorageSourceAttachApply
qemu: hotplug: Extract hotplug of TLS into
qemuBlockStorageSourceAttachApply
qemu: command: Rename qemuBuildDiskDriveCommandLine
qemu: command: Extract setup of one disk's command line
qemu: command: Refactor disk commandline formatting
src/qemu/qemu_alias.c | 4 +-
src/qemu/qemu_alias.h | 2 +-
src/qemu/qemu_block.c | 58 +++++++++++-
src/qemu/qemu_block.h | 16 ++++
src/qemu/qemu_command.c | 232 +++++++++++++++++++++++++++++-----------------
src/qemu/qemu_command.h | 13 ++-
src/qemu/qemu_driver.c | 18 ++--
src/qemu/qemu_hotplug.c | 121 +++---------------------
src/qemu/qemu_migration.c | 6 +-
src/qemu/qemu_process.c | 2 +-
10 files changed, 257 insertions(+), 215 deletions(-)
--
2.16.2
6 years, 6 months
[libvirt] [PATCH] bhyve: add support for passing stdin to loader
by Fabian Freyer
This commit adds the <bootloader_stdin> node to the domain definition,
with the following semantics:
To pass standard input verbatim to the bootloader, set
<bootloader_stdin>some stdin</bootloader_stdin>
Multiline standard input can be set using a CDATA tag:
<bootloader_stdin><![CDATA[
this standard input
will be passed in with
newlines and indentation.
]]></bootloader_stdin>
Standard input can be read from a file as follows:
<bootloader_stdin file="/path/to/some/file"/>
Signed-off-by: Fabian Freyer <fabian.freyer(a)physik.tu-berlin.de>
---
docs/formatdomain.html.in | 19 ++++++
docs/schemas/domaincommon.rng | 10 ++++
src/bhyve/bhyve_driver.c | 10 ++++
src/bhyve/bhyve_parse_command.c | 70 ++++++++++++++++++++++
src/bhyve/bhyve_process.c | 22 +++++++
src/conf/domain_conf.c | 41 +++++++++++++
src/conf/domain_conf.h | 11 ++++
.../bhyveargv2xml-loader-stdin-file.args | 9 +++
.../bhyveargv2xml-loader-stdin-file.xml | 19 ++++++
.../bhyveargv2xml-loader-stdin-multiline.args | 13 ++++
.../bhyveargv2xml-loader-stdin-multiline.xml | 21 +++++++
.../bhyveargv2xml-loader-stdin-oneline.args | 11 ++++
.../bhyveargv2xml-loader-stdin-oneline.xml | 19 ++++++
tests/bhyveargv2xmltest.c | 3 +
.../bhyvexml2argv-grub-stdin-file.args | 9 +++
.../bhyvexml2argv-grub-stdin-file.devmap | 1 +
.../bhyvexml2argv-grub-stdin-file.ldargs | 4 ++
.../bhyvexml2argv-grub-stdin-file.xml | 25 ++++++++
.../bhyvexml2argv-grub-stdin-multiline.args | 9 +++
.../bhyvexml2argv-grub-stdin-multiline.devmap | 1 +
.../bhyvexml2argv-grub-stdin-multiline.ldargs | 4 ++
.../bhyvexml2argv-grub-stdin-multiline.xml | 30 ++++++++++
.../bhyvexml2argv-grub-stdin-oneline.args | 9 +++
.../bhyvexml2argv-grub-stdin-oneline.devmap | 1 +
.../bhyvexml2argv-grub-stdin-oneline.ldargs | 4 ++
.../bhyvexml2argv-grub-stdin-oneline.xml | 25 ++++++++
tests/bhyvexml2argvtest.c | 3 +
.../bhyvexml2xmlout-grub-stdin-file.xml | 34 +++++++++++
.../bhyvexml2xmlout-grub-stdin-multiline.xml | 39 ++++++++++++
.../bhyvexml2xmlout-grub-stdin-oneline.xml | 34 +++++++++++
tests/bhyvexml2xmltest.c | 3 +
31 files changed, 513 insertions(+)
create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-loader-stdin-file.args
create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-loader-stdin-file.xml
create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-loader-stdin-multiline.args
create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-loader-stdin-multiline.xml
create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-loader-stdin-oneline.args
create mode 100644 tests/bhyveargv2xmldata/bhyveargv2xml-loader-stdin-oneline.xml
create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-grub-stdin-file.args
create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-grub-stdin-file.devmap
create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-grub-stdin-file.ldargs
create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-grub-stdin-file.xml
create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-grub-stdin-multiline.args
create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-grub-stdin-multiline.devmap
create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-grub-stdin-multiline.ldargs
create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-grub-stdin-multiline.xml
create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-grub-stdin-oneline.args
create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-grub-stdin-oneline.devmap
create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-grub-stdin-oneline.ldargs
create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-grub-stdin-oneline.xml
create mode 100644 tests/bhyvexml2xmloutdata/bhyvexml2xmlout-grub-stdin-file.xml
create mode 100644 tests/bhyvexml2xmloutdata/bhyvexml2xmlout-grub-stdin-multiline.xml
create mode 100644 tests/bhyvexml2xmloutdata/bhyvexml2xmlout-grub-stdin-oneline.xml
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 5e99884dc..cea024235 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -245,6 +245,11 @@
...
<bootloader>/usr/bin/pygrub</bootloader>
<bootloader_args>--append single</bootloader_args>
+<bootloader_stdin><![CDATA[
+kernel (hd)/path/to/kernel
+initrd (host)/path/to/initrd
+boot
+]]>
...</pre>
<dl>
@@ -259,6 +264,20 @@
command line arguments to be passed to the bootloader.
<span class="since">Since 0.2.3</span>
</dd>
+ <dt><code>bootloader_stdin</code></dt>
+ <dd>The optional <code>bootloader_stdin</code> element specifies
+ standard input to be passed to the bootloader. To pass multiple
+ lines of standard input to the bootloader, wrap the content in
+ a CDATA tag. Instead of specifying the standard input in the
+ domain XML, the path to a file to be read may be given using the
+ <code>file</code> attribute:
+<pre>
+...
+<bootloader_stdin file="/path/to/some/file"/>
+...
+</pre>
+ <span class="since">Since 4.3.0 (bhyve only)</span>
+ </dd>
</dl>
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 4cab55f05..a44d88ef3 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -1211,6 +1211,16 @@
<text/>
</element>
</optional>
+ <optional>
+ <choice>
+ <element name="bootloader_stdin">
+ <text/>
+ </element>
+ <element name="bootloader_stdin">
+ <attribute name="file"/>
+ </element>
+ </choice>
+ </optional>
</interleave>
</define>
<define name="osbootkernel">
diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c
index 24c4a9c80..7ac3ad3f0 100644
--- a/src/bhyve/bhyve_driver.c
+++ b/src/bhyve/bhyve_driver.c
@@ -743,6 +743,16 @@ bhyveConnectDomainXMLToNative(virConnectPtr conn,
goto cleanup;
virBufferAdd(&buf, virCommandToString(loadcmd), -1);
+
+ if (def->os.bootloaderStdinSource == VIR_DOMAIN_BOOTLOADER_STDIN_FILE)
+ virBufferEscapeString(&buf, " < %s", def->os.bootloaderStdin);
+ else if (def->os.bootloaderStdinSource
+ == VIR_DOMAIN_BOOTLOADER_STDIN_LITERAL) {
+ virBufferEscapeString(&buf, " << END_LOADER_STDIN\n"
+ "%s\nEND_LOADER_STDIN",
+ def->os.bootloaderStdin);
+ }
+
virBufferAddChar(&buf, '\n');
}
diff --git a/src/bhyve/bhyve_parse_command.c b/src/bhyve/bhyve_parse_command.c
index fcaaed275..ef51a75f1 100644
--- a/src/bhyve/bhyve_parse_command.c
+++ b/src/bhyve/bhyve_parse_command.c
@@ -124,6 +124,8 @@ static int
bhyveCommandLineToArgv(const char *nativeConfig,
int *loader_argc,
char ***loader_argv,
+ char **loader_stdin_buffer,
+ char **loader_stdin_file,
int *bhyve_argc,
char ***bhyve_argv)
{
@@ -139,6 +141,10 @@ bhyveCommandLineToArgv(const char *nativeConfig,
char **_bhyve_argv = NULL;
char **_loader_argv = NULL;
+ virBuffer heredoc = VIR_BUFFER_INITIALIZER;
+ int in_heredoc = 0;
+ char *heredoc_delim = NULL;
+
nativeConfig_unescaped = bhyveParseCommandLineUnescape(nativeConfig);
if (nativeConfig_unescaped == NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
@@ -178,6 +184,52 @@ bhyveCommandLineToArgv(const char *nativeConfig,
char **arglist = NULL;
size_t args_count = 0;
size_t args_alloc = 0;
+ char *stdin_redir = NULL;
+
+ /* are we in a heredoc? */
+ if ( in_heredoc ) {
+ if (STRPREFIX(curr, heredoc_delim)) {
+ in_heredoc = 0;
+ *loader_stdin_buffer = virBufferContentAndReset(&heredoc);
+ continue;
+ }
+
+ if (in_heredoc++ == 1)
+ virBufferAsprintf(&heredoc, "%s", curr);
+ else
+ virBufferAsprintf(&heredoc, "\n%s", curr);
+
+ continue;
+ }
+
+ /* check if this line contains standard input redirection. */
+ if ( (stdin_redir = strchr(curr, '<')) ) {
+ if (STREQLEN(stdin_redir, "<<", 2)) {
+ *stdin_redir = '\0';
+ in_heredoc = 1;
+ heredoc_delim = stdin_redir + 2;
+
+ /* skip non-alphanumeric chars */
+ while (*heredoc_delim && !c_isalnum(*heredoc_delim))
+ heredoc_delim ++;
+
+ if (!*heredoc_delim)
+ goto error;
+
+ virBufferFreeAndReset(&heredoc);
+ } else {
+ /* file redirection */
+ *stdin_redir = '\0';
+ stdin_redir ++;
+
+ /* skip non-alphanumeric chars */
+ while (*stdin_redir && !c_isalnum(*stdin_redir))
+ stdin_redir ++;
+
+ if (VIR_STRDUP(*loader_stdin_file, stdin_redir) != 1)
+ goto error;
+ }
+ }
/* iterate over each line, splitting on sequences of ' '. This code is
* adapted from qemu/qemu_parse_command.c. */
@@ -254,12 +306,16 @@ bhyveCommandLineToArgv(const char *nativeConfig,
if (!(*bhyve_argv = _bhyve_argv))
goto error;
+ if (in_heredoc)
+ goto error;
+
virStringListFree(lines);
return 0;
error:
VIR_FREE(_loader_argv);
VIR_FREE(_bhyve_argv);
+ virBufferFreeAndReset(&heredoc);
virStringListFree(lines);
return -1;
}
@@ -869,6 +925,8 @@ bhyveParseCommandLineString(const char* nativeConfig,
char **bhyve_argv = NULL;
int loader_argc = 0;
char **loader_argv = NULL;
+ char *loader_stdin_file = NULL;
+ char *loader_stdin_buffer = NULL;
if (!(def = virDomainDefNew()))
goto cleanup;
@@ -887,12 +945,21 @@ bhyveParseCommandLineString(const char* nativeConfig,
if (bhyveCommandLineToArgv(nativeConfig,
&loader_argc, &loader_argv,
+ &loader_stdin_buffer, &loader_stdin_file,
&bhyve_argc, &bhyve_argv)) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Failed to convert the command string to argv-lists"));
goto error;
}
+ if (loader_stdin_file && !loader_stdin_buffer) {
+ def->os.bootloaderStdinSource = VIR_DOMAIN_BOOTLOADER_STDIN_FILE;
+ def->os.bootloaderStdin = loader_stdin_file;
+ } else if (loader_stdin_buffer && !loader_stdin_file) {
+ def->os.bootloaderStdinSource = VIR_DOMAIN_BOOTLOADER_STDIN_LITERAL,
+ def->os.bootloaderStdin = loader_stdin_buffer;
+ }
+
if (bhyveParseBhyveCommandLine(def, xmlopt, caps, bhyve_argc, bhyve_argv))
goto error;
if (loader_argv && STREQ(loader_argv[0], "/usr/sbin/bhyveload")) {
@@ -906,9 +973,12 @@ bhyveParseCommandLineString(const char* nativeConfig,
cleanup:
virStringListFree(loader_argv);
virStringListFree(bhyve_argv);
+
return def;
error:
virDomainDefFree(def);
+ VIR_FREE(loader_stdin_buffer);
+ VIR_FREE(loader_stdin_file);
def = NULL;
goto cleanup;
}
diff --git a/src/bhyve/bhyve_process.c b/src/bhyve/bhyve_process.c
index 9276d7d36..1a6f783d7 100644
--- a/src/bhyve/bhyve_process.c
+++ b/src/bhyve/bhyve_process.c
@@ -113,6 +113,7 @@ virBhyveProcessStart(virConnectPtr conn,
bhyveDomainObjPrivatePtr priv = vm->privateData;
int ret = -1, rc;
virCapsPtr caps = NULL;
+ int stdinfd = -1;
if (virAsprintf(&logfile, "%s/%s.log",
BHYVE_LOG_DIR, vm->def->name) < 0)
@@ -173,6 +174,26 @@ virBhyveProcessStart(virConnectPtr conn,
if (!(load_cmd = virBhyveProcessBuildLoadCmd(conn, vm->def, devmap_file,
&devicemap)))
goto cleanup;
+
+ switch (vm->def->os.bootloaderStdinSource) {
+ case VIR_DOMAIN_BOOTLOADER_STDIN_NONE:
+ break;
+ case VIR_DOMAIN_BOOTLOADER_STDIN_FILE:
+ if ((stdinfd = open(vm->def->os.bootloaderStdin, O_RDONLY)) < 0) {
+ virReportSystemError(errno, _("Failed to open '%s'"),
+ vm->def->os.bootloaderStdin);
+ goto cleanup;
+ }
+ virCommandSetInputFD(load_cmd, stdinfd);
+ break;
+ case VIR_DOMAIN_BOOTLOADER_STDIN_LITERAL:
+ virCommandSetInputBuffer(load_cmd, vm->def->os.bootloaderStdin);
+ break;
+ /* coverity[dead_error_begin] */
+ case VIR_DOMAIN_BOOTLOADER_STDIN_LAST:
+ break;
+ }
+
virCommandSetOutputFD(load_cmd, &logfd);
virCommandSetErrorFD(load_cmd, &logfd);
@@ -252,6 +273,7 @@ virBhyveProcessStart(virConnectPtr conn,
virCommandFree(load_cmd);
virCommandFree(cmd);
VIR_FREE(logfile);
+ VIR_FORCE_CLOSE(stdinfd);
VIR_FORCE_CLOSE(logfd);
return ret;
}
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index d23182f18..d99ecf9f7 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -3037,6 +3037,8 @@ void virDomainDefFree(virDomainDefPtr def)
VIR_FREE(def->os.bootloader);
VIR_FREE(def->os.bootloaderArgs);
+ VIR_FREE(def->os.bootloaderStdin);
+
virDomainClockDefClear(&def->clock);
VIR_FREE(def->name);
@@ -18700,6 +18702,16 @@ virDomainDefParseXML(xmlDocPtr xml,
def->os.bootloader = virXPathString("string(./bootloader)", ctxt);
def->os.bootloaderArgs = virXPathString("string(./bootloader_args)", ctxt);
+ if ((def->os.bootloaderStdin = virXPathString("string(./bootloader_stdin/"
+ "@file)", ctxt)))
+ def->os.bootloaderStdinSource = VIR_DOMAIN_BOOTLOADER_STDIN_FILE;
+ else if ((def->os.bootloaderStdin = virXPathString("string("
+ "./bootloader_stdin)",
+ ctxt)))
+ def->os.bootloaderStdinSource = VIR_DOMAIN_BOOTLOADER_STDIN_LITERAL;
+ else
+ def->os.bootloaderStdinSource = VIR_DOMAIN_BOOTLOADER_STDIN_NONE;
+
tmp = virXPathString("string(./os/type[1])", ctxt);
if (!tmp) {
if (def->os.bootloader) {
@@ -26717,6 +26729,35 @@ virDomainDefFormatInternal(virDomainDefPtr def,
virBufferEscapeString(buf,
"<bootloader_args>%s</bootloader_args>\n",
def->os.bootloaderArgs);
+
+ switch (def->os.bootloaderStdinSource) {
+ case VIR_DOMAIN_BOOTLOADER_STDIN_NONE:
+ break;
+ case VIR_DOMAIN_BOOTLOADER_STDIN_FILE:
+ virBufferEscapeString(buf, "<bootloader_stdin file=\"%s\"/>\n",
+ def->os.bootloaderStdin);
+ break;
+ case VIR_DOMAIN_BOOTLOADER_STDIN_LITERAL:
+ if (strchr(def->os.bootloaderStdin, '\n')
+ || strchr(def->os.bootloaderStdin, '<')
+ || strchr(def->os.bootloaderStdin, '>')
+ || strchr(def->os.bootloaderStdin, '&'))
+ {
+ virBufferEscapeString(buf,
+ "<bootloader_stdin><![CDATA[%s]]>"
+ "</bootloader_stdin>\n",
+ def->os.bootloaderStdin);
+ } else {
+ virBufferEscapeString(buf,
+ "<bootloader_stdin>%s"
+ "</bootloader_stdin>\n",
+ def->os.bootloaderStdin);
+ }
+ break;
+ /* coverity[dead_error_begin] */
+ case VIR_DOMAIN_BOOTLOADER_STDIN_LAST:
+ break;
+ }
}
virBufferAddLit(buf, "<os>\n");
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index bbaa24137..41af6cc8a 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1897,6 +1897,15 @@ struct _virDomainOSEnv {
char *value;
};
+/* Bootloader standard input source */
+typedef enum {
+ VIR_DOMAIN_BOOTLOADER_STDIN_NONE = 0,
+ VIR_DOMAIN_BOOTLOADER_STDIN_FILE,
+ VIR_DOMAIN_BOOTLOADER_STDIN_LITERAL,
+
+ VIR_DOMAIN_BOOTLOADER_STDIN_LAST
+} virDomainBootloaderStdinSource;
+
typedef struct _virDomainOSDef virDomainOSDef;
typedef virDomainOSDef *virDomainOSDefPtr;
struct _virDomainOSDef {
@@ -1923,6 +1932,8 @@ struct _virDomainOSDef {
virDomainLoaderDefPtr loader;
char *bootloader;
char *bootloaderArgs;
+ virDomainBootloaderStdinSource bootloaderStdinSource;
+ char *bootloaderStdin;
int smbios_mode;
virDomainBIOSDef bios;
diff --git a/tests/bhyveargv2xmldata/bhyveargv2xml-loader-stdin-file.args b/tests/bhyveargv2xmldata/bhyveargv2xml-loader-stdin-file.args
new file mode 100644
index 000000000..ca51f2f04
--- /dev/null
+++ b/tests/bhyveargv2xmldata/bhyveargv2xml-loader-stdin-file.args
@@ -0,0 +1,9 @@
+/usr/bin/custom-loader \
+-s ome \
+--args < path/to/some/file
+/usr/sbin/bhyve \
+-c 1 \
+-m 214 \
+-H \
+-P \
+-s 0:0,hostbridge bhyve
diff --git a/tests/bhyveargv2xmldata/bhyveargv2xml-loader-stdin-file.xml b/tests/bhyveargv2xmldata/bhyveargv2xml-loader-stdin-file.xml
new file mode 100644
index 000000000..a56a4c451
--- /dev/null
+++ b/tests/bhyveargv2xmldata/bhyveargv2xml-loader-stdin-file.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>
+ <vcpu placement='static'>1</vcpu>
+ <bootloader>/usr/bin/custom-loader</bootloader>
+ <bootloader_args>-s ome --args</bootloader_args>
+ <bootloader_stdin file="path/to/some/file"/>
+ <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/bhyveargv2xmldata/bhyveargv2xml-loader-stdin-multiline.args b/tests/bhyveargv2xmldata/bhyveargv2xml-loader-stdin-multiline.args
new file mode 100644
index 000000000..050ddf442
--- /dev/null
+++ b/tests/bhyveargv2xmldata/bhyveargv2xml-loader-stdin-multiline.args
@@ -0,0 +1,13 @@
+/usr/bin/custom-loader \
+-s ome \
+--args << END_OF_THIS_HEREDOC
+some
+standard input
+here
+END_OF_THIS_HEREDOC
+/usr/sbin/bhyve \
+-c 1 \
+-m 214 \
+-H \
+-P \
+-s 0:0,hostbridge bhyve
diff --git a/tests/bhyveargv2xmldata/bhyveargv2xml-loader-stdin-multiline.xml b/tests/bhyveargv2xmldata/bhyveargv2xml-loader-stdin-multiline.xml
new file mode 100644
index 000000000..496b5ea87
--- /dev/null
+++ b/tests/bhyveargv2xmldata/bhyveargv2xml-loader-stdin-multiline.xml
@@ -0,0 +1,21 @@
+<domain type='bhyve'>
+ <name>bhyve</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory unit='KiB'>219136</memory>
+ <currentMemory unit='KiB'>219136</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <bootloader>/usr/bin/custom-loader</bootloader>
+ <bootloader_args>-s ome --args</bootloader_args>
+ <bootloader_stdin><![CDATA[some
+standard input
+here]]></bootloader_stdin>
+ <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/bhyveargv2xmldata/bhyveargv2xml-loader-stdin-oneline.args b/tests/bhyveargv2xmldata/bhyveargv2xml-loader-stdin-oneline.args
new file mode 100644
index 000000000..f8bcdcddd
--- /dev/null
+++ b/tests/bhyveargv2xmldata/bhyveargv2xml-loader-stdin-oneline.args
@@ -0,0 +1,11 @@
+/usr/bin/custom-loader \
+-s ome \
+--args << END_OF_THIS_HEREDOC
+some standard input here
+END_OF_THIS_HEREDOC
+/usr/sbin/bhyve \
+-c 1 \
+-m 214 \
+-H \
+-P \
+-s 0:0,hostbridge bhyve
diff --git a/tests/bhyveargv2xmldata/bhyveargv2xml-loader-stdin-oneline.xml b/tests/bhyveargv2xmldata/bhyveargv2xml-loader-stdin-oneline.xml
new file mode 100644
index 000000000..17c9da664
--- /dev/null
+++ b/tests/bhyveargv2xmldata/bhyveargv2xml-loader-stdin-oneline.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>
+ <vcpu placement='static'>1</vcpu>
+ <bootloader>/usr/bin/custom-loader</bootloader>
+ <bootloader_args>-s ome --args</bootloader_args>
+ <bootloader_stdin>some standard input here</bootloader_stdin>
+ <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..fef01d7da 100644
--- a/tests/bhyveargv2xmltest.c
+++ b/tests/bhyveargv2xmltest.c
@@ -187,6 +187,9 @@ mymain(void)
DO_TEST("memsize-human");
DO_TEST_FAIL("memsize-fail");
DO_TEST("custom-loader");
+ DO_TEST("loader-stdin-file");
+ DO_TEST("loader-stdin-oneline");
+ DO_TEST("loader-stdin-multiline");
DO_TEST("bhyveload-custom");
DO_TEST("bhyveload-vda");
DO_TEST_FAIL("bhyveload-name-mismatch");
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-grub-stdin-file.args b/tests/bhyvexml2argvdata/bhyvexml2argv-grub-stdin-file.args
new file mode 100644
index 000000000..3ba5c1160
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-grub-stdin-file.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:ee:f5:79 bhyve
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-grub-stdin-file.devmap b/tests/bhyvexml2argvdata/bhyvexml2argv-grub-stdin-file.devmap
new file mode 100644
index 000000000..b312bfdaf
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-grub-stdin-file.devmap
@@ -0,0 +1 @@
+(hd0) /tmp/freebsd.img
\ No newline at end of file
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-grub-stdin-file.ldargs b/tests/bhyvexml2argvdata/bhyvexml2argv-grub-stdin-file.ldargs
new file mode 100644
index 000000000..7d9a5155a
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-grub-stdin-file.ldargs
@@ -0,0 +1,4 @@
+/usr/local/sbin/grub-bhyve \
+--root hd0,msdos1 \
+--device-map '<device.map>' \
+--memory 214 bhyve
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-grub-stdin-file.xml b/tests/bhyvexml2argvdata/bhyvexml2argv-grub-stdin-file.xml
new file mode 100644
index 000000000..f804da0db
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-grub-stdin-file.xml
@@ -0,0 +1,25 @@
+<domain type='bhyve'>
+ <name>bhyve</name>
+ <uuid>df3be7e7-a104-11e3-aeb0-50e5492bd3dc</uuid>
+ <memory>219136</memory>
+ <vcpu>1</vcpu>
+ <bootloader>/usr/local/sbin/grub-bhyve</bootloader>
+ <bootloader_stdin file="/path/to/some/file"/>
+ <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:ee:f5:79'/>
+ <model type='virtio'/>
+ <source bridge="virbr0"/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+ </interface>
+ </devices>
+</domain>
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-grub-stdin-multiline.args b/tests/bhyvexml2argvdata/bhyvexml2argv-grub-stdin-multiline.args
new file mode 100644
index 000000000..3ba5c1160
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-grub-stdin-multiline.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:ee:f5:79 bhyve
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-grub-stdin-multiline.devmap b/tests/bhyvexml2argvdata/bhyvexml2argv-grub-stdin-multiline.devmap
new file mode 100644
index 000000000..b312bfdaf
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-grub-stdin-multiline.devmap
@@ -0,0 +1 @@
+(hd0) /tmp/freebsd.img
\ No newline at end of file
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-grub-stdin-multiline.ldargs b/tests/bhyvexml2argvdata/bhyvexml2argv-grub-stdin-multiline.ldargs
new file mode 100644
index 000000000..7d9a5155a
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-grub-stdin-multiline.ldargs
@@ -0,0 +1,4 @@
+/usr/local/sbin/grub-bhyve \
+--root hd0,msdos1 \
+--device-map '<device.map>' \
+--memory 214 bhyve
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-grub-stdin-multiline.xml b/tests/bhyvexml2argvdata/bhyvexml2argv-grub-stdin-multiline.xml
new file mode 100644
index 000000000..456ab0443
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-grub-stdin-multiline.xml
@@ -0,0 +1,30 @@
+<domain type='bhyve'>
+ <name>bhyve</name>
+ <uuid>df3be7e7-a104-11e3-aeb0-50e5492bd3dc</uuid>
+ <memory>219136</memory>
+ <vcpu>1</vcpu>
+ <bootloader>/usr/local/sbin/grub-bhyve</bootloader>
+ <bootloader_stdin><![CDATA[
+multiple
+boot
+loader
+commands
+]]></bootloader_stdin>
+ <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:ee:f5:79'/>
+ <model type='virtio'/>
+ <source bridge="virbr0"/>
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+ </interface>
+ </devices>
+</domain>
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-grub-stdin-oneline.args b/tests/bhyvexml2argvdata/bhyvexml2argv-grub-stdin-oneline.args
new file mode 100644
index 000000000..3ba5c1160
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-grub-stdin-oneline.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:ee:f5:79 bhyve
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-grub-stdin-oneline.devmap b/tests/bhyvexml2argvdata/bhyvexml2argv-grub-stdin-oneline.devmap
new file mode 100644
index 000000000..b312bfdaf
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-grub-stdin-oneline.devmap
@@ -0,0 +1 @@
+(hd0) /tmp/freebsd.img
\ No newline at end of file
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-grub-stdin-oneline.ldargs b/tests/bhyvexml2argvdata/bhyvexml2argv-grub-stdin-oneline.ldargs
new file mode 100644
index 000000000..7d9a5155a
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-grub-stdin-oneline.ldargs
@@ -0,0 +1,4 @@
+/usr/local/sbin/grub-bhyve \
+--root hd0,msdos1 \
+--device-map '<device.map>' \
+--memory 214 bhyve
diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-grub-stdin-oneline.xml b/tests/bhyvexml2argvdata/bhyvexml2argv-grub-stdin-oneline.xml
new file mode 100644
index 000000000..03b6987fd
--- /dev/null
+++ b/tests/bhyvexml2argvdata/bhyvexml2argv-grub-stdin-oneline.xml
@@ -0,0 +1,25 @@
+<domain type='bhyve'>
+ <name>bhyve</name>
+ <uuid>df3be7e7-a104-11e3-aeb0-50e5492bd3dc</uuid>
+ <memory>219136</memory>
+ <vcpu>1</vcpu>
+ <bootloader>/usr/local/sbin/grub-bhyve</bootloader>
+ <bootloader_stdin>some input commands</bootloader_stdin>
+ <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:ee:f5:79'/>
+ <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..e4cb0592e 100644
--- a/tests/bhyvexml2argvtest.c
+++ b/tests/bhyvexml2argvtest.c
@@ -188,6 +188,9 @@ mymain(void)
DO_TEST("grub-defaults");
DO_TEST("grub-bootorder");
DO_TEST("grub-bootorder2");
+ DO_TEST("grub-stdin-file");
+ DO_TEST("grub-stdin-oneline");
+ DO_TEST("grub-stdin-multiline");
DO_TEST("bhyveload-bootorder");
DO_TEST("bhyveload-bootorder1");
DO_TEST_FAILURE("bhyveload-bootorder2");
diff --git a/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-grub-stdin-file.xml b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-grub-stdin-file.xml
new file mode 100644
index 000000000..f07368d01
--- /dev/null
+++ b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-grub-stdin-file.xml
@@ -0,0 +1,34 @@
+<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>
+ <bootloader>/usr/local/sbin/grub-bhyve</bootloader>
+ <bootloader_stdin file="/path/to/some/file"/>
+ <os>
+ <type arch='x86_64'>hvm</type>
+ </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:ee:f5:79'/>
+ <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-grub-stdin-multiline.xml b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-grub-stdin-multiline.xml
new file mode 100644
index 000000000..eae6df4b4
--- /dev/null
+++ b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-grub-stdin-multiline.xml
@@ -0,0 +1,39 @@
+<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>
+ <bootloader>/usr/local/sbin/grub-bhyve</bootloader>
+ <bootloader_stdin><![CDATA[
+multiple
+boot
+loader
+commands
+]]></bootloader_stdin>
+ <os>
+ <type arch='x86_64'>hvm</type>
+ </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:ee:f5:79'/>
+ <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-grub-stdin-oneline.xml b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-grub-stdin-oneline.xml
new file mode 100644
index 000000000..b038a9065
--- /dev/null
+++ b/tests/bhyvexml2xmloutdata/bhyvexml2xmlout-grub-stdin-oneline.xml
@@ -0,0 +1,34 @@
+<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>
+ <bootloader>/usr/local/sbin/grub-bhyve</bootloader>
+ <bootloader_stdin>some input commands</bootloader_stdin>
+ <os>
+ <type arch='x86_64'>hvm</type>
+ </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:ee:f5:79'/>
+ <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..fd386b504 100644
--- a/tests/bhyvexml2xmltest.c
+++ b/tests/bhyvexml2xmltest.c
@@ -98,6 +98,9 @@ mymain(void)
DO_TEST_DIFFERENT("grub-bootorder");
DO_TEST_DIFFERENT("grub-bootorder2");
DO_TEST_DIFFERENT("grub-defaults");
+ DO_TEST_DIFFERENT("grub-stdin-file");
+ DO_TEST_DIFFERENT("grub-stdin-oneline");
+ DO_TEST_DIFFERENT("grub-stdin-multiline");
DO_TEST_DIFFERENT("localtime");
DO_TEST_DIFFERENT("macaddr");
DO_TEST_DIFFERENT("metadata");
--
2.11.0
6 years, 6 months
[libvirt] [PATCH 0/5] Add support for extended TSEG
by Martin Kletzander
QEMU enabled setting the value in 2.10 and it also chose some value secretly
that we need to keep so that the guest works as it should've before. Also to be
sure nothing changes in case QEMU changes its default, since it's visible from
the guest.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1469338
If you are interested in lot of juicy info how the stuff is related to
everything in the observable universe, I recommend reading through the comments
of the BZ. In his unlimited knowledge, Laszlo was so kind to explain all the
underlying plumbing into details. Thanks Laszlo! Laszlo FTW! ;-)
Martin Kletzander (5):
docs: Tiny fix for the SMM description
qemu: Move checks for SMM from command-line creation into validation
phase
conf, schema, docs: Add support for TSEG size setting
qemu: Add capability flag for setting the extended tseg size
qemu: Add support for setting the TSEG size
docs/formatdomain.html.in | 45 ++++++++-
docs/schemas/domaincommon.rng | 5 +
src/conf/domain_conf.c | 60 +++++++++++-
src/conf/domain_conf.h | 1 +
src/qemu/qemu_capabilities.c | 31 ++++--
src/qemu/qemu_capabilities.h | 6 +-
src/qemu/qemu_command.c | 30 ++++--
src/qemu/qemu_domain.c | 96 ++++++++++++++++++-
tests/genericxml2xmlindata/tseg.xml | 23 +++++
tests/genericxml2xmltest.c | 2 +
.../caps_1.5.3.x86_64.replies | 38 ++++++--
.../caps_1.5.3.x86_64.xml | 3 +-
.../caps_1.6.0.x86_64.replies | 38 ++++++--
.../caps_1.6.0.x86_64.xml | 3 +-
.../caps_1.7.0.x86_64.replies | 38 ++++++--
.../caps_1.7.0.x86_64.xml | 3 +-
.../caps_2.1.1.x86_64.replies | 38 ++++++--
.../caps_2.1.1.x86_64.xml | 3 +-
.../caps_2.10.0.x86_64.replies | 48 +++++++---
.../caps_2.10.0.x86_64.xml | 3 +-
.../caps_2.12.0.x86_64.replies | 67 ++++++++++---
.../caps_2.12.0.x86_64.xml | 4 +-
.../caps_2.4.0.x86_64.replies | 38 ++++++--
.../caps_2.4.0.x86_64.xml | 3 +-
.../caps_2.5.0.x86_64.replies | 40 ++++++--
.../caps_2.5.0.x86_64.xml | 3 +-
.../caps_2.6.0.x86_64.replies | 40 ++++++--
.../caps_2.6.0.x86_64.xml | 3 +-
.../caps_2.7.0.x86_64.replies | 40 ++++++--
.../caps_2.7.0.x86_64.xml | 3 +-
.../caps_2.8.0.x86_64.replies | 40 ++++++--
.../caps_2.8.0.x86_64.xml | 3 +-
.../caps_2.9.0.x86_64.replies | 48 +++++++---
.../caps_2.9.0.x86_64.xml | 3 +-
.../qemuxml2argvdata/tseg-explicit-size.args | 28 ++++++
tests/qemuxml2argvdata/tseg-explicit-size.xml | 23 +++++
tests/qemuxml2argvdata/tseg-i440fx.xml | 23 +++++
tests/qemuxml2argvdata/tseg-invalid-size.xml | 23 +++++
.../tseg-old-machine-type.args | 27 ++++++
.../tseg-old-machine-type.xml | 21 ++++
tests/qemuxml2argvdata/tseg.args | 28 ++++++
tests/qemuxml2argvdata/tseg.xml | 21 ++++
tests/qemuxml2argvtest.c | 48 ++++++++++
.../qemuxml2xmloutdata/tseg-explicit-size.xml | 46 +++++++++
.../tseg-old-machine-type.xml | 44 +++++++++
tests/qemuxml2xmloutdata/tseg.xml | 46 +++++++++
tests/qemuxml2xmltest.c | 25 +++++
47 files changed, 1123 insertions(+), 129 deletions(-)
create mode 100644 tests/genericxml2xmlindata/tseg.xml
create mode 100644 tests/qemuxml2argvdata/tseg-explicit-size.args
create mode 100644 tests/qemuxml2argvdata/tseg-explicit-size.xml
create mode 100644 tests/qemuxml2argvdata/tseg-i440fx.xml
create mode 100644 tests/qemuxml2argvdata/tseg-invalid-size.xml
create mode 100644 tests/qemuxml2argvdata/tseg-old-machine-type.args
create mode 100644 tests/qemuxml2argvdata/tseg-old-machine-type.xml
create mode 100644 tests/qemuxml2argvdata/tseg.args
create mode 100644 tests/qemuxml2argvdata/tseg.xml
create mode 100644 tests/qemuxml2xmloutdata/tseg-explicit-size.xml
create mode 100644 tests/qemuxml2xmloutdata/tseg-old-machine-type.xml
create mode 100644 tests/qemuxml2xmloutdata/tseg.xml
--
2.17.0
6 years, 6 months
[libvirt] [PATCH v2 0/2] qemu: Forbid qcow/qcow2 native encryption
by Peter Krempa
v2:
- add entries to formatdomain.html and formatstorageencryption.html
saying that the encryption should not be used.
This applies on top of my branch collecting all ACKed postings of
recent blockdev-related work. Current version can be fetched by:
git fetch git://pipo.sk/pipo/libvirt.git blockdev-staging
Peter Krempa (2):
qemu: domain: Forbid storage with old QCOW2 encryption
qemu: Remove code for setting up disk passphrases
docs/formatdomain.html.in | 4 +
docs/formatstorageencryption.html.in | 5 +-
src/qemu/qemu_domain.c | 10 +++
src/qemu/qemu_monitor.c | 13 ---
src/qemu/qemu_monitor.h | 4 -
src/qemu/qemu_monitor_json.c | 28 ------
src/qemu/qemu_monitor_json.h | 4 -
src/qemu/qemu_process.c | 103 -----------------------
tests/qemumonitorjsontest.c | 2 -
tests/qemuxml2argvdata/encrypted-disk-usage.args | 8 +-
tests/qemuxml2argvdata/encrypted-disk-usage.xml | 2 +-
tests/qemuxml2argvdata/encrypted-disk.args | 8 +-
tests/qemuxml2argvdata/encrypted-disk.xml | 2 +-
tests/qemuxml2argvtest.c | 4 +-
tests/qemuxml2xmloutdata/encrypted-disk.xml | 2 +-
tests/qemuxml2xmltest.c | 4 +-
16 files changed, 37 insertions(+), 166 deletions(-)
--
2.16.2
6 years, 6 months
[libvirt] [PATCH 0/4] qemu: Handle managed persisten reservations separately
by Peter Krempa
Keep the handling of the singleton managed pr-manager-helper object
separate from the unmanaged ones which are instantiated
one-per-disk-source.
This applies on top of my branch collecting all ACKed postings of
recent blockdev-related work. Current version can be fetched by:
git fetch git://pipo.sk/pipo/libvirt.git blockdev-staging
Peter Krempa (4):
util: storage: Add helper for determining whether a backing chain
requires PR
qemu: command: Pass in 'src' rather than 'disk' to
qemuBuildPRManagerInfoProps
qemu: command: Return props as return value in
qemuBuildPRManagerInfoProps
qemu: Split handling of managed and unmanaged persistent reservations
src/conf/domain_conf.c | 2 +-
src/libvirt_private.syms | 1 +
src/qemu/qemu_command.c | 123 ++++++++++++++-------
src/qemu/qemu_command.h | 4 +-
src/qemu/qemu_hotplug.c | 101 ++++++++---------
src/util/virstoragefile.c | 14 +++
src/util/virstoragefile.h | 3 +
...isk-virtio-scsi-reservations.x86_64-latest.args | 4 +-
8 files changed, 154 insertions(+), 98 deletions(-)
--
2.16.2
6 years, 6 months