[libvirt] [tck PATCH v2 00/13] Make sure all tests pass
by Daniel P. Berrangé
I went through and fixed every single broken test, so everything should
now pass when run against latest git master.
Daniel P. Berrangé (13):
scripts: avoid using multicast MAC addresses
scripts: strip quotes from URI before checking it
scripts: fix block info test conditions
scripts: remove testing of 'cow' format
scripts: portability fixes in checking command output
scripts: cope with multiple seclabels in live XML
scripts: switch to using luks encryption with QEMU
scripts: skip luks test entirely for now
scripts: fix the various hotplug tests
scripts: don't abort the entire test harness when libvirtd isn't
running
scripts: re-enable save/restore test
lib: don't re-assign $_
lib: allow marking the scratch disk as shareable
lib/Sys/Virt/TCK.pm | 6 +++++-
lib/Sys/Virt/TCK/DomainBuilder.pm | 7 +++++--
lib/Sys/Virt/TCK/Hooks.pm | 5 ++---
lib/Sys/Virt/TCK/StorageVolBuilder.pm | 18 +++++++++++++-----
scripts/domain/081-unique-id-create.t | 4 ++--
scripts/domain/102-broken-save-restore.t | 3 +--
scripts/domain/121-block-info.t | 5 ++---
scripts/domain/200-disk-hotplug.t | 4 +++-
scripts/domain/205-disk-hotplug-ordering.t | 5 ++++-
scripts/domain/210-nic-hotplug.t | 5 ++++-
scripts/domain/215-nic-hotplug-many.t | 11 +++++++----
scripts/hooks/051-daemon-hook.t | 2 +-
scripts/hooks/052-domain-hook.t | 14 +++++++++-----
scripts/networks/networkApplyTest.sh | 2 +-
.../networkxml2hostout/tck-testnet-1.dat | 2 +-
.../networkxml2hostout/tck-testnet-2.dat | 2 +-
.../networkxml2hostout/tck-testnet-3.dat | 4 ++--
scripts/nwfilter/nwfilter2vmtest.sh | 2 +-
scripts/nwfilter/nwfilter_concurrent.sh | 2 +-
scripts/qemu/100-disk-encryption.t | 3 +++
scripts/selinux/100-static-relabel-no.t | 4 ++--
scripts/selinux/110-static-relabel-yes.t | 6 +++---
scripts/storage/100-create-vol-dir.t | 19 +------------------
scripts/storage/200-clone-vol-dir.t | 4 ++--
24 files changed, 76 insertions(+), 63 deletions(-)
--
2.17.0
6 years, 6 months
[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] 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 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
[libvirt] [PATCH v2 0/3] qemu: Add TLS transport for NBD
by Peter Krempa
v2:
- added qemu.conf knobs
- added docs
- fixed test case for changes in ACKed patches
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 (3):
qemu: conf: Add qemu.conf knobs for setting up TLS for NBD
qemu: domain: Add support for TLS for NBD
tests: qemublock: Test NBD with TLS in the JSON generator
docs/formatdomain.html.in | 8 ++++-
docs/schemas/domaincommon.rng | 5 +++
src/qemu/libvirtd_qemu.aug | 4 +++
src/qemu/qemu.conf | 34 +++++++++++++++++++
src/qemu/qemu_command.c | 5 +++
src/qemu/qemu_conf.c | 15 +++++++++
src/qemu/qemu_conf.h | 3 ++
src/qemu/qemu_domain.c | 38 ++++++++++++++++++++--
src/qemu/test_libvirtd_qemu.aug.in | 2 ++
tests/qemublocktest.c | 1 +
.../xml2json/network-nbd-tls.json | 19 +++++++++++
.../qemublocktestdata/xml2json/network-nbd-tls.xml | 18 ++++++++++
.../disk-drive-network-tlsx509.args | 9 ++++-
.../disk-drive-network-tlsx509.xml | 8 +++++
tests/qemuxml2argvtest.c | 2 +-
.../disk-drive-network-tlsx509.xml | 8 +++++
16 files changed, 174 insertions(+), 5 deletions(-)
create mode 100644 tests/qemublocktestdata/xml2json/network-nbd-tls.json
create mode 100644 tests/qemublocktestdata/xml2json/network-nbd-tls.xml
--
2.16.2
6 years, 6 months
[libvirt] [PATCH] libxl: fix leaking logfile fds
by Jim Fehlig
Per-domain log files were introduced in commit a30b08b7179. The FILE
objects associated with these log files are stored in a hash table
using domid as a key. When a domain is shutdown, destroyed, or
otherwise powered-off, the FILE object is removed from the hash table,
where the free function will close the FILE.
Unfortunately the call to remove the FILE from the hash table occurs
after setting domid=-1 in the libxlDomainCleanup() function. The
object is never removed from the hash table, the free function is
never called, and the underlying fd is leaked. Fix by removing the
FILE object from the hash table before setting domid=-1.
Signed-off-by: Jim Fehlig <jfehlig(a)suse.com>
---
src/libxl/libxl_domain.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c
index d4859d6707..d12b1b1b4b 100644
--- a/src/libxl/libxl_domain.c
+++ b/src/libxl/libxl_domain.c
@@ -769,6 +769,7 @@ libxlDomainCleanup(libxlDriverPrivatePtr driver,
VIR_WARN("Unable to release lease on %s", vm->def->name);
VIR_DEBUG("Preserving lock state '%s'", NULLSTR(priv->lockState));
+ libxlLoggerCloseFile(cfg->logger, vm->def->id);
vm->def->id = -1;
if (priv->deathW) {
@@ -822,8 +823,6 @@ libxlDomainCleanup(libxlDriverPrivatePtr driver,
VIR_FREE(xml);
}
- libxlLoggerCloseFile(cfg->logger, vm->def->id);
-
virDomainObjRemoveTransientDef(vm);
virObjectUnref(cfg);
}
--
2.16.3
6 years, 7 months
Re: [libvirt] [libvirt-users] virRandomBits - not very random
by Eric Blake
Reviving an ancient thread:
On 11/04/2014 02:18 AM, Daniel P. Berrange wrote:
> On Mon, Nov 03, 2014 at 11:09:12AM -0500, Brian Rak wrote:
>> I just ran into an issue where I had about 30 guests get duplicate mac
>> addresses assigned. These were scattered across 30 different machines.
>>
>> Some debugging revealed that:
>>
>> 1) All the host machines were restarted within a couple seconds of each
>> other
>> 2) All the host machines had fairly similar libvirtd pids (within ~100 PIDs
>> of each other)
>> 3) Libvirt seeds the RNG using 'time(NULL) ^ getpid()'
>>
>> This perfectly explains why I saw so many duplicate mac addresses.
>>
>> Why is the RNG seed such a predictable value? Surely there has to be a
>> better source of a random seed then the timestamp and the pid?
>>
>> The PID seems to me to be a very bad source of any randomness. I just ran a
>> test across 60 of our hosts. 43 of them shared their PID with at least one
>> other machine.
>
> We should probably seed it with data from /dev/urandom, and/or the new
> Linux getrandom() syscall (or BSD equivalent).
Did anyone ever open a BZ to track this? As far as I can tell, we still
have a very predictable (meaning bad) seeding algorithm that permits
large clusters to create collisions when their random number sequences
sync up.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
6 years, 7 months
[libvirt] [PATCH 00/10] Use better PRNG
by Michal Privoznik
This is inspired by bug reported here [1]. Even though Eric suggested
calling this Linux syscall when building without gnutls [2] I've decided
to not implement it. Firstly, we build with gnuls everywhere (even
Windows), secondly I see no appealing reason to special case Linux -
/dev/urandom is good for both Linux and FreeBSD.
Once these are merged I'm probably going to send patch set that makes
gnutls mandatory. I'm tired of all those WITH_GNUTLS if-defs (esp. in
function arguments). But that is orthogonal to what I'm solving here.
Also, I'm not quite sure this is a release material, so I'm fine with
merging this after the release.
1: https://www.redhat.com/archives/libvirt-users/2018-May/msg00097.html
2: https://www.redhat.com/archives/libvirt-users/2018-May/msg00100.html
Michal Privoznik (10):
virRandomBytes: Fix return value
virCryptoGenerateRandom: rename ret
virCryptoGenerateRandom: Explain gnults error
virCryptoGenerateRandom: Don't allocate return buffer
virRandomBytes: Prefer saferead over plain read
virRandomBytes: Report error
virRandomBytes: Use gnutls_rnd whenever possible
virrandom: Make virRandomBits better
virUUIDGenerate don't fall back to virRandomBits
vircrypto: Drop virCryptoGenerateRandom
src/libvirt_private.syms | 1 -
src/qemu/qemu_domain.c | 13 ++++--
src/util/vircrypto.c | 41 -------------------
src/util/vircrypto.h | 2 -
src/util/virrandom.c | 103 ++++++++++++++++-------------------------------
src/util/viruuid.c | 25 ++----------
tests/qemuxml2argvmock.c | 13 ------
tests/vircryptotest.c | 4 +-
8 files changed, 48 insertions(+), 154 deletions(-)
--
2.16.1
6 years, 7 months