[libvirt] [PATCH] conf: don't ignore <target dev='blah'/> for macvtap interfaces
by Laine Stump
The parser had been clearing out *all* suggested device names for
type='direct' (aka macvtap) interfaces. All of the code implementing
macvtap allows for a user-specified device name, so we should allow
it. In the case that an interface name starts with "macvtap" or
"macvlan" though, we do still clear it out, just as we do with "vnet"
(which is the prefix used for automatically generated tap device
names), since those are the prefixes for the names we autogenerate for
macvtap and macvlan devices.
Resolves: https://bugzilla.redhat.com/1335798
---
docs/formatdomain.html.in | 6 +++---
src/conf/domain_conf.c | 6 +++++-
src/conf/domain_conf.h | 4 ++++
3 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 4a3123e..8a2294f 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -5125,9 +5125,9 @@ qemu-kvm -net nic,model=? /dev/null
If no target is specified, certain hypervisors will
automatically generate a name for the created tun device. This
name can be manually specified, however the name <i>should not
- start with either 'vnet' or 'vif'</i>, which are prefixes
- reserved by libvirt and certain hypervisors. Manually specified
- targets using these prefixes may be ignored.
+ start with either 'vnet', 'vif', 'macvtap', or 'macvlan'</i>,
+ which are prefixes reserved by libvirt and certain hypervisors.
+ Manually specified targets using these prefixes may be ignored.
</p>
<p>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 2139ab0..4b80018 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -9826,8 +9826,12 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
def->data.direct.linkdev = dev;
dev = NULL;
- if (flags & VIR_DOMAIN_DEF_PARSE_INACTIVE)
+ if (ifname &&
+ flags & VIR_DOMAIN_DEF_PARSE_INACTIVE &&
+ (STRPREFIX(ifname, VIR_NET_GENERATED_MACVTAP_PREFIX) ||
+ STRPREFIX(ifname, VIR_NET_GENERATED_MACVTAP_PREFIX))) {
VIR_FREE(ifname);
+ }
break;
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 8e6d874..38a15f1 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1033,6 +1033,10 @@ struct _virDomainNetDef {
* by libvirt, and cannot be used for a persistent network name. */
# define VIR_NET_GENERATED_PREFIX "vnet"
+/* except to macvtap/macvlan interfaces, which start with "macv(tap|lan) */
+# define VIR_NET_GENERATED_MACVTAP_PREFIX "macvtap"
+# define VIR_NET_GENERATED_MACVLAN_PREFIX "macvlan"
+
typedef enum {
VIR_DOMAIN_CHR_DEVICE_STATE_DEFAULT = 0,
VIR_DOMAIN_CHR_DEVICE_STATE_CONNECTED,
--
2.9.3
7 years, 8 months
[libvirt] Question about qemuDomainLogContextNew()
by Feng Feng24 Liu
Hi, Dear all
I have a question, and need your help.
I want to output some log message to "/var/log/libvirt/qemu/instance-xxxxxx" when guest kernel crashed, so I add following the code:
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
static int
qemuProcessHandleGuestPanic(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
virDomainObjPtr vm,
void *opaque)
{
......
+ qemuDomainLogContextPtr logCtxt = NULL;
+ if (!(logCtxt = qemuDomainLogContextNew(driver, vm, QEMU_DOMAIN_LOG_CONTEXT_MODE_START))){
+ VIR_WARN("Unable to open domainlog");
+ goto cleanup;
+ }
......
}
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
But this code cannot get the logCtxt,
logCtxt = qemuDomainLogContextNew(driver, vm, QEMU_DOMAIN_LOG_CONTEXT_MODE_START) always return NULL, so I CANNOT write message to log file.
Really Need your help, Thanks!
Thanks
Feng
7 years, 8 months
[libvirt] [PATCH v4 00/10] Add TLS support for migration
by John Ferlan
v3: http://www.redhat.com/archives/libvir-list/2017-March/msg00878.html
Changes from v1
Patch 1: Fix the (false); to (0)
Patch 2: New to adjust the other (false); in qemu_conf.c
Patch 3: Alter the text slightly - also found that the client parameters
are only required if *tls_x509_verify = 1, so adjust the descriptions
to reflect that
Patch 4: Alter the vnc_* and chardev_* descriptions to match the migrate_*
Patch 5: Previous patch 3, ACK'd
Patch 6: Previous patch 4, altered comments
Patch 7: Previous patch 5, fixed commit message
Patch 8: Previous patch 6, multiple changes:
- Reduced verbosity of comments
- Rework the ResetTLS logic (combined code, fetched tls-creds if
necessary again)
- Add the qemuProcessRecoverMigrationIn call to ResetTLS in
the FINISH3 stage
Patch 9: Previous patch 7, alter based on patch 7 adjustments vis-a-vis ResetTLS
Patch 10: Previous patch 8, alter text of description to include "migrate"
All changes were tested in my nested virt environment...
A virsh qemu-monitor-command $DOM '{"execute":"query-migrate-parameters"}'
after the migrations were completed (back and forth) returned "" for tls-creds
and tls-hostname for each hostname (incoming and outgoing tests).
John Ferlan (10):
qemu: Create #define for TLS configuration setup.
qemu: Replace macro usage of (false); with just (0)
conf: Introduce migrate_tls_x509_cert_dir
qemu: Update the TLS client verify descriptions for vnc and chardev
Add new migration flag VIR_MIGRATE_TLS
qemu: Add TLS params to _qemuMonitorMigrationParams
qemu: Add job for qemuDomain{Add|Del}TLSObjects
qemu: Set up the migration TLS objects for target
qemu: Set up the migration TLS objects for source
docs: Add news entry for Migration using TLS
docs/news.xml | 8 +
include/libvirt/libvirt-domain.h | 8 +
src/qemu/libvirtd_qemu.aug | 5 +
src/qemu/qemu.conf | 63 ++++++-
src/qemu/qemu_conf.c | 47 +++--
src/qemu/qemu_conf.h | 4 +
src/qemu/qemu_domain.c | 7 +-
src/qemu/qemu_domain.h | 91 ++++++----
src/qemu/qemu_driver.c | 4 +-
src/qemu/qemu_hotplug.c | 24 ++-
src/qemu/qemu_hotplug.h | 2 +
src/qemu/qemu_migration.c | 363 ++++++++++++++++++++++++++++++++++++-
src/qemu/qemu_migration.h | 16 +-
src/qemu/qemu_monitor.c | 11 +-
src/qemu/qemu_monitor.h | 5 +
src/qemu/qemu_monitor_json.c | 21 +++
src/qemu/qemu_process.c | 3 +
src/qemu/test_libvirtd_qemu.aug.in | 3 +
tests/qemumonitorjsontest.c | 25 ++-
tools/virsh-domain.c | 7 +
20 files changed, 641 insertions(+), 76 deletions(-)
--
2.9.3
7 years, 8 months
[libvirt] [PATCH 1/2] bhyve: helper function to probe hypervisor caps
by Roman Bogorodskiy
There are a number of functions in bhyve_capabilities.c that probe
hypervisor capabilities by executing the bhyve(1) binary with the
specific device arugment, checking error message (if any) and setting
proper capability bit. As those are extremely similar, move this logic
into a helper function and convert existing functions to use that.
---
src/bhyve/bhyve_capabilities.c | 122 +++++++++++++++++------------------------
1 file changed, 49 insertions(+), 73 deletions(-)
diff --git a/src/bhyve/bhyve_capabilities.c b/src/bhyve/bhyve_capabilities.c
index 4bf1d84fa..f72fdea41 100644
--- a/src/bhyve/bhyve_capabilities.c
+++ b/src/bhyve/bhyve_capabilities.c
@@ -193,121 +193,97 @@ virBhyveProbeGrubCaps(virBhyveGrubCapsFlags *caps)
}
static int
-bhyveProbeCapsRTC_UTC(unsigned int *caps, char *binary)
+bhyveProbeCapsDeviceHelper(unsigned int *caps,
+ char *binary,
+ const char *bus,
+ const char *device,
+ const char *errormsg,
+ unsigned int flag)
{
- char *help;
+ char *error;
virCommandPtr cmd = NULL;
- int ret = 0, exit;
+ int ret = -1, exit;
cmd = virCommandNew(binary);
- virCommandAddArg(cmd, "-h");
- virCommandSetErrorBuffer(cmd, &help);
- if (virCommandRun(cmd, &exit) < 0) {
- ret = -1;
- goto out;
- }
+ virCommandAddArgList(cmd, bus, device, NULL);
+ virCommandSetErrorBuffer(cmd, &error);
+ if (virCommandRun(cmd, &exit) < 0)
+ goto cleanup;
- if (strstr(help, "-u:") != NULL)
- *caps |= BHYVE_CAP_RTC_UTC;
+ if (strstr(error, errormsg) == NULL)
+ *caps |= flag;
- out:
- VIR_FREE(help);
+ ret = 0;
+ cleanup:
+ VIR_FREE(error);
virCommandFree(cmd);
return ret;
}
static int
-bhyveProbeCapsAHCI32Slot(unsigned int *caps, char *binary)
+bhyveProbeCapsRTC_UTC(unsigned int *caps, char *binary)
{
- char *error;
+ char *help;
virCommandPtr cmd = NULL;
int ret = 0, exit;
cmd = virCommandNew(binary);
- virCommandAddArgList(cmd, "-s", "0,ahci", NULL);
- virCommandSetErrorBuffer(cmd, &error);
+ virCommandAddArg(cmd, "-h");
+ virCommandSetErrorBuffer(cmd, &help);
if (virCommandRun(cmd, &exit) < 0) {
ret = -1;
goto out;
}
- if (strstr(error, "pci slot 0:0: unknown device \"ahci\"") == NULL)
- *caps |= BHYVE_CAP_AHCI32SLOT;
+ if (strstr(help, "-u:") != NULL)
+ *caps |= BHYVE_CAP_RTC_UTC;
out:
- VIR_FREE(error);
+ VIR_FREE(help);
virCommandFree(cmd);
return ret;
}
static int
-bhyveProbeCapsNetE1000(unsigned int *caps, char *binary)
+bhyveProbeCapsAHCI32Slot(unsigned int *caps, char *binary)
{
- char *error;
- virCommandPtr cmd = NULL;
- int ret = -1, exit;
-
- cmd = virCommandNew(binary);
- virCommandAddArgList(cmd, "-s", "0,e1000", NULL);
- virCommandSetErrorBuffer(cmd, &error);
- if (virCommandRun(cmd, &exit) < 0)
- goto cleanup;
+ return bhyveProbeCapsDeviceHelper(caps, binary,
+ "-s",
+ "0,ahci",
+ "pci slot 0:0: unknown device \"ahci\"",
+ BHYVE_CAP_AHCI32SLOT);
+}
- if (strstr(error, "pci slot 0:0: unknown device \"e1000\"") == NULL)
- *caps |= BHYVE_CAP_NET_E1000;
- ret = 0;
- cleanup:
- VIR_FREE(error);
- virCommandFree(cmd);
- return ret;
+static int
+bhyveProbeCapsNetE1000(unsigned int *caps, char *binary)
+{
+ return bhyveProbeCapsDeviceHelper(caps, binary,
+ "-s",
+ "0,e1000",
+ "pci slot 0:0: unknown device \"e1000\"",
+ BHYVE_CAP_NET_E1000);
}
static int
bhyveProbeCapsLPC_Bootrom(unsigned int *caps, char *binary)
{
- char *error;
- virCommandPtr cmd = NULL;
- int ret = -1, exit;
-
- cmd = virCommandNew(binary);
- virCommandAddArgList(cmd, "-l", "bootrom", NULL);
- virCommandSetErrorBuffer(cmd, &error);
- if (virCommandRun(cmd, &exit) < 0)
- goto cleanup;
-
- if (strstr(error, "bhyve: invalid lpc device configuration 'bootrom'") == NULL)
- *caps |= BHYVE_CAP_LPC_BOOTROM;
-
- ret = 0;
- cleanup:
- VIR_FREE(error);
- virCommandFree(cmd);
- return ret;
+ return bhyveProbeCapsDeviceHelper(caps, binary,
+ "-l",
+ "bootrom",
+ "bhyve: invalid lpc device configuration 'bootrom'",
+ BHYVE_CAP_LPC_BOOTROM);
}
static int
bhyveProbeCapsFramebuffer(unsigned int *caps, char *binary)
{
- char *error;
- virCommandPtr cmd = NULL;
- int ret = -1, exit;
-
- cmd = virCommandNew(binary);
- virCommandAddArgList(cmd, "-s", "0,fbuf", NULL);
- virCommandSetErrorBuffer(cmd, &error);
- if (virCommandRun(cmd, &exit) < 0)
- goto cleanup;
-
- if (strstr(error, "pci slot 0:0: unknown device \"fbuf\"") == NULL)
- *caps |= BHYVE_CAP_FBUF;
-
- ret = 0;
- cleanup:
- VIR_FREE(error);
- virCommandFree(cmd);
- return ret;
+ return bhyveProbeCapsDeviceHelper(caps, binary,
+ "-s",
+ "0,fbuf",
+ "pci slot 0:0: unknown device \"fbuf\"",
+ BHYVE_CAP_FBUF);
}
int
--
2.11.0
7 years, 8 months
[libvirt] [PATCH] domaincapstest: add bhyve caps test
by Roman Bogorodskiy
* Extract filling bhyve capabilities from virBhyveDomainCapsBuild()
into a new function virBhyveDomainCapsFill() to make testing
easier by not having to mock firmware directory listing and
hypervisor capabilities probing
* Also, just presence of the firmware files is not sufficient
to enable os.loader.supported, hypervisor should support UEFI
boot too
* Add tests to domaincapstest for the main caps possible flows:
- when UEFI bootrom is supported
- when video (fbus) is supported
- neither of above is supported
---
src/bhyve/bhyve_capabilities.c | 72 +++++++++++++++--------
src/bhyve/bhyve_capabilities.h | 3 +
tests/Makefile.am | 4 ++
tests/domaincapsschemadata/bhyve_basic.x86_64.xml | 32 ++++++++++
tests/domaincapsschemadata/bhyve_fbuf.x86_64.xml | 49 +++++++++++++++
tests/domaincapsschemadata/bhyve_uefi.x86_64.xml | 41 +++++++++++++
tests/domaincapstest.c | 65 ++++++++++++++++++++
7 files changed, 242 insertions(+), 24 deletions(-)
create mode 100644 tests/domaincapsschemadata/bhyve_basic.x86_64.xml
create mode 100644 tests/domaincapsschemadata/bhyve_fbuf.x86_64.xml
create mode 100644 tests/domaincapsschemadata/bhyve_uefi.x86_64.xml
diff --git a/src/bhyve/bhyve_capabilities.c b/src/bhyve/bhyve_capabilities.c
index 4bf1d84fa..6f8be45c4 100644
--- a/src/bhyve/bhyve_capabilities.c
+++ b/src/bhyve/bhyve_capabilities.c
@@ -87,6 +87,44 @@ virBhyveCapsBuild(void)
return NULL;
}
+int
+virBhyveDomainCapsFill(virDomainCapsPtr caps,
+ unsigned int bhyvecaps,
+ virDomainCapsStringValuesPtr firmwares)
+{
+ caps->disk.supported = true;
+ VIR_DOMAIN_CAPS_ENUM_SET(caps->disk.diskDevice,
+ VIR_DOMAIN_DISK_DEVICE_DISK,
+ VIR_DOMAIN_DISK_DEVICE_CDROM);
+
+ VIR_DOMAIN_CAPS_ENUM_SET(caps->disk.bus,
+ VIR_DOMAIN_DISK_BUS_SATA,
+ VIR_DOMAIN_DISK_BUS_VIRTIO);
+
+ caps->os.supported = true;
+
+ if (bhyvecaps & BHYVE_CAP_LPC_BOOTROM) {
+ caps->os.loader.supported = true;
+ VIR_DOMAIN_CAPS_ENUM_SET(caps->os.loader.type,
+ VIR_DOMAIN_LOADER_TYPE_PFLASH);
+ VIR_DOMAIN_CAPS_ENUM_SET(caps->os.loader.readonly,
+ VIR_TRISTATE_BOOL_YES);
+
+ caps->os.loader.values.values = firmwares->values;
+ caps->os.loader.values.nvalues = firmwares->nvalues;
+ }
+
+
+ if (bhyvecaps & BHYVE_CAP_FBUF) {
+ caps->graphics.supported = true;
+ caps->video.supported = true;
+ VIR_DOMAIN_CAPS_ENUM_SET(caps->graphics.type, VIR_DOMAIN_GRAPHICS_TYPE_VNC);
+ VIR_DOMAIN_CAPS_ENUM_SET(caps->video.modelType, VIR_DOMAIN_VIDEO_TYPE_GOP);
+ }
+ return 0;
+}
+
+
virDomainCapsPtr
virBhyveDomainCapsBuild(bhyveConnPtr conn,
const char *emulatorbin,
@@ -101,6 +139,7 @@ virBhyveDomainCapsBuild(bhyveConnPtr conn,
size_t firmwares_alloc = 0;
virBhyveDriverConfigPtr cfg = virBhyveDriverGetConfig(conn);
const char *firmware_dir = cfg->firmwareDir;
+ virDomainCapsStringValuesPtr firmwares = NULL;
if (!(caps = virDomainCapsNew(emulatorbin, machine, arch, virttype)))
goto cleanup;
@@ -111,46 +150,31 @@ virBhyveDomainCapsBuild(bhyveConnPtr conn,
goto cleanup;
}
- caps->os.supported = true;
- caps->os.loader.supported = true;
- VIR_DOMAIN_CAPS_ENUM_SET(caps->os.loader.type,
- VIR_DOMAIN_LOADER_TYPE_PFLASH);
- VIR_DOMAIN_CAPS_ENUM_SET(caps->os.loader.readonly,
- VIR_TRISTATE_BOOL_YES);
+ if (VIR_ALLOC(firmwares) < 0)
+ goto cleanup;
if (virDirOpenIfExists(&dir, firmware_dir) > 0) {
while ((virDirRead(dir, &entry, firmware_dir)) > 0) {
- if (VIR_RESIZE_N(caps->os.loader.values.values,
- firmwares_alloc, caps->os.loader.values.nvalues, 2) < 0)
+ if (VIR_RESIZE_N(firmwares->values,
+ firmwares_alloc, firmwares->nvalues, 1) < 0)
goto cleanup;
if (virAsprintf(
- &caps->os.loader.values.values[caps->os.loader.values.nvalues],
+ &firmwares->values[firmwares->nvalues],
"%s/%s", firmware_dir, entry->d_name) < 0)
goto cleanup;
- caps->os.loader.values.nvalues++;
+ firmwares->nvalues++;
}
} else {
VIR_WARN("Cannot open firmware directory %s", firmware_dir);
}
- caps->disk.supported = true;
- VIR_DOMAIN_CAPS_ENUM_SET(caps->disk.diskDevice,
- VIR_DOMAIN_DISK_DEVICE_DISK,
- VIR_DOMAIN_DISK_DEVICE_CDROM);
-
- VIR_DOMAIN_CAPS_ENUM_SET(caps->disk.bus,
- VIR_DOMAIN_DISK_BUS_SATA,
- VIR_DOMAIN_DISK_BUS_VIRTIO);
+ if (virBhyveDomainCapsFill(caps, bhyve_caps, firmwares) < 0)
+ goto cleanup;
- if (bhyve_caps & BHYVE_CAP_FBUF) {
- caps->graphics.supported = true;
- caps->video.supported = true;
- VIR_DOMAIN_CAPS_ENUM_SET(caps->graphics.type, VIR_DOMAIN_GRAPHICS_TYPE_VNC);
- VIR_DOMAIN_CAPS_ENUM_SET(caps->video.modelType, VIR_DOMAIN_VIDEO_TYPE_GOP);
- }
cleanup:
+ VIR_FREE(firmwares);
VIR_DIR_CLOSE(dir);
virObjectUnref(cfg);
return caps;
diff --git a/src/bhyve/bhyve_capabilities.h b/src/bhyve/bhyve_capabilities.h
index 3db4f1b88..194061fde 100644
--- a/src/bhyve/bhyve_capabilities.h
+++ b/src/bhyve/bhyve_capabilities.h
@@ -28,6 +28,9 @@
# include "bhyve_utils.h"
virCapsPtr virBhyveCapsBuild(void);
+int virBhyveDomainCapsFill(virDomainCapsPtr caps,
+ unsigned int bhyvecaps,
+ virDomainCapsStringValuesPtr firmwares);
virDomainCapsPtr virBhyveDomainCapsBuild(bhyveConnPtr,
const char *emulatorbin,
const char *machine,
diff --git a/tests/Makefile.am b/tests/Makefile.am
index af69a3a84..d4eedaf17 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -964,6 +964,10 @@ domaincapstest_SOURCES += testutilsxen.c testutilsxen.h
domaincapstest_LDADD += ../src/libvirt_driver_libxl_impl.la $(GNULIB_LIBS)
endif WITH_LIBXL
+if WITH_BHYVE
+domaincapstest_LDADD += ../src/libvirt_driver_bhyve_impl.la $(GNULIB_LIBS)
+endif WITH_BHYVE
+
virnetmessagetest_SOURCES = \
virnetmessagetest.c testutils.h testutils.c
virnetmessagetest_CFLAGS = $(XDR_CFLAGS) $(AM_CFLAGS)
diff --git a/tests/domaincapsschemadata/bhyve_basic.x86_64.xml b/tests/domaincapsschemadata/bhyve_basic.x86_64.xml
new file mode 100644
index 000000000..f6dfabed2
--- /dev/null
+++ b/tests/domaincapsschemadata/bhyve_basic.x86_64.xml
@@ -0,0 +1,32 @@
+<domainCapabilities>
+ <path>/usr/sbin/bhyve</path>
+ <domain>bhyve</domain>
+ <machine>(null)</machine>
+ <arch>x86_64</arch>
+ <os supported='yes'>
+ <loader supported='no'/>
+ </os>
+ <cpu>
+ <mode name='host-passthrough' supported='no'/>
+ <mode name='host-model' supported='no'/>
+ <mode name='custom' supported='no'/>
+ </cpu>
+ <devices>
+ <disk supported='yes'>
+ <enum name='diskDevice'>
+ <value>disk</value>
+ <value>cdrom</value>
+ </enum>
+ <enum name='bus'>
+ <value>virtio</value>
+ <value>sata</value>
+ </enum>
+ </disk>
+ <graphics supported='no'/>
+ <video supported='no'/>
+ <hostdev supported='no'/>
+ </devices>
+ <features>
+ <gic supported='no'/>
+ </features>
+</domainCapabilities>
diff --git a/tests/domaincapsschemadata/bhyve_fbuf.x86_64.xml b/tests/domaincapsschemadata/bhyve_fbuf.x86_64.xml
new file mode 100644
index 000000000..6fec72c89
--- /dev/null
+++ b/tests/domaincapsschemadata/bhyve_fbuf.x86_64.xml
@@ -0,0 +1,49 @@
+<domainCapabilities>
+ <path>/usr/sbin/bhyve</path>
+ <domain>bhyve</domain>
+ <machine>(null)</machine>
+ <arch>x86_64</arch>
+ <os supported='yes'>
+ <loader supported='yes'>
+ <value>/foo/bar</value>
+ <value>/foo/baz</value>
+ <enum name='type'>
+ <value>pflash</value>
+ </enum>
+ <enum name='readonly'>
+ <value>yes</value>
+ </enum>
+ </loader>
+ </os>
+ <cpu>
+ <mode name='host-passthrough' supported='no'/>
+ <mode name='host-model' supported='no'/>
+ <mode name='custom' supported='no'/>
+ </cpu>
+ <devices>
+ <disk supported='yes'>
+ <enum name='diskDevice'>
+ <value>disk</value>
+ <value>cdrom</value>
+ </enum>
+ <enum name='bus'>
+ <value>virtio</value>
+ <value>sata</value>
+ </enum>
+ </disk>
+ <graphics supported='yes'>
+ <enum name='type'>
+ <value>vnc</value>
+ </enum>
+ </graphics>
+ <video supported='yes'>
+ <enum name='modelType'>
+ <value>gop</value>
+ </enum>
+ </video>
+ <hostdev supported='no'/>
+ </devices>
+ <features>
+ <gic supported='no'/>
+ </features>
+</domainCapabilities>
diff --git a/tests/domaincapsschemadata/bhyve_uefi.x86_64.xml b/tests/domaincapsschemadata/bhyve_uefi.x86_64.xml
new file mode 100644
index 000000000..c0b5c161b
--- /dev/null
+++ b/tests/domaincapsschemadata/bhyve_uefi.x86_64.xml
@@ -0,0 +1,41 @@
+<domainCapabilities>
+ <path>/usr/sbin/bhyve</path>
+ <domain>bhyve</domain>
+ <machine>(null)</machine>
+ <arch>x86_64</arch>
+ <os supported='yes'>
+ <loader supported='yes'>
+ <value>/foo/bar</value>
+ <value>/foo/baz</value>
+ <enum name='type'>
+ <value>pflash</value>
+ </enum>
+ <enum name='readonly'>
+ <value>yes</value>
+ </enum>
+ </loader>
+ </os>
+ <cpu>
+ <mode name='host-passthrough' supported='no'/>
+ <mode name='host-model' supported='no'/>
+ <mode name='custom' supported='no'/>
+ </cpu>
+ <devices>
+ <disk supported='yes'>
+ <enum name='diskDevice'>
+ <value>disk</value>
+ <value>cdrom</value>
+ </enum>
+ <enum name='bus'>
+ <value>virtio</value>
+ <value>sata</value>
+ </enum>
+ </disk>
+ <graphics supported='no'/>
+ <video supported='no'/>
+ <hostdev supported='no'/>
+ </devices>
+ <features>
+ <gic supported='no'/>
+ </features>
+</domainCapabilities>
diff --git a/tests/domaincapstest.c b/tests/domaincapstest.c
index a4bc8d6d0..c61a5c05f 100644
--- a/tests/domaincapstest.c
+++ b/tests/domaincapstest.c
@@ -273,12 +273,37 @@ fillXenCaps(virDomainCapsPtr domCaps)
}
#endif /* WITH_LIBXL */
+#ifdef WITH_BHYVE
+# include "bhyve/bhyve_capabilities.h"
+
+static int
+fillBhyveCaps(virDomainCapsPtr domCaps, unsigned int *bhyve_caps)
+{
+ virDomainCapsStringValuesPtr firmwares = NULL;
+ int ret = -1;
+
+ if (VIR_ALLOC(firmwares) < 0)
+ return -1;
+
+ if (fillStringValues(firmwares, "/foo/bar", "/foo/baz", NULL) < 0)
+ goto cleanup;
+
+ if (virBhyveDomainCapsFill(domCaps, *bhyve_caps, firmwares) < 0)
+ goto cleanup;
+
+ ret = 0;
+ cleanup:
+ VIR_FREE(firmwares);
+ return ret;
+}
+#endif /* WITH_BHYVE */
enum testCapsType {
CAPS_NONE,
CAPS_ALL,
CAPS_QEMU,
CAPS_LIBXL,
+ CAPS_BHYVE,
};
struct testData {
@@ -333,6 +358,12 @@ test_virDomainCapsFormat(const void *opaque)
goto cleanup;
#endif
break;
+ case CAPS_BHYVE:
+#if WITH_BHYVE
+ if (fillBhyveCaps(domCaps, data->capsOpaque) < 0)
+ goto cleanup;
+#endif
+ break;
}
if (!(domCapsXML = virDomainCapsFormat(domCaps)))
@@ -354,6 +385,10 @@ mymain(void)
{
int ret = 0;
+#if WITH_BHYVE
+ unsigned int bhyve_caps = 0;
+#endif
+
#if WITH_QEMU
virQEMUDriverConfigPtr cfg = virQEMUDriverConfigNew(false);
@@ -419,6 +454,26 @@ mymain(void)
DO_TEST("full", "/bin/emulatorbin", "my-machine-type",
"x86_64", VIR_DOMAIN_VIRT_KVM, CAPS_ALL);
+#define DO_TEST_BHYVE(Name, Emulator, BhyveCaps, Type) \
+ do { \
+ char *name = NULL; \
+ if (virAsprintf(&name, "bhyve_%s.x86_64", Name) < 0) { \
+ ret = -1; \
+ break; \
+ } \
+ struct testData data = { \
+ .name = name, \
+ .emulator = Emulator, \
+ .arch = "x86_64", \
+ .type = Type, \
+ .capsType = CAPS_BHYVE, \
+ .capsOpaque = BhyveCaps, \
+ }; \
+ if (virTestRun(name, test_virDomainCapsFormat, &data) < 0) \
+ ret = -1; \
+ VIR_FREE(name); \
+ } while (0)
+
#if WITH_QEMU
DO_TEST_QEMU("1.7.0", "caps_1.7.0",
@@ -488,6 +543,16 @@ mymain(void)
#endif /* WITH_LIBXL */
+#if WITH_BHYVE
+ DO_TEST_BHYVE("basic", "/usr/sbin/bhyve", &bhyve_caps, VIR_DOMAIN_VIRT_BHYVE);
+
+ bhyve_caps |= BHYVE_CAP_LPC_BOOTROM;
+ DO_TEST_BHYVE("uefi", "/usr/sbin/bhyve", &bhyve_caps, VIR_DOMAIN_VIRT_BHYVE);
+
+ bhyve_caps |= BHYVE_CAP_FBUF;
+ DO_TEST_BHYVE("fbuf", "/usr/sbin/bhyve", &bhyve_caps, VIR_DOMAIN_VIRT_BHYVE);
+#endif /* WITH_BHYVE */
+
return ret;
}
--
2.11.0
7 years, 8 months
[libvirt] [PATCH] domain_capabilities: Don't report machine type for bhyve
by Michal Privoznik
For some drivers the domain's machine type makes no sense. They
just don't use it. A great example is bhyve driver. Therefore it
makes very less sense to report machine in domain capabilities
XML.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
docs/formatdomaincaps.html.in | 3 ++-
src/conf/domain_capabilities.c | 3 ++-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/docs/formatdomaincaps.html.in b/docs/formatdomaincaps.html.in
index 648e3d481..007cab62d 100644
--- a/docs/formatdomaincaps.html.in
+++ b/docs/formatdomaincaps.html.in
@@ -70,7 +70,8 @@
<dt><code>machine</code></dt>
<dd>The domain's <a href="formatdomain.html#elementsOSBIOS">machine
- type</a>.</dd>
+ type</a>. Since not every hypervisor has a sense of machine types
+ this element might be omitted in such drivers.</dd>
<dt><code>arch</code></dt>
<dd>The domain's <a href="formatdomain.html#elementsOSBIOS">
diff --git a/src/conf/domain_capabilities.c b/src/conf/domain_capabilities.c
index bb6742359..7a3d2e6fb 100644
--- a/src/conf/domain_capabilities.c
+++ b/src/conf/domain_capabilities.c
@@ -527,7 +527,8 @@ virDomainCapsFormatInternal(virBufferPtr buf,
virBufferEscapeString(buf, "<path>%s</path>\n", caps->path);
virBufferAsprintf(buf, "<domain>%s</domain>\n", virttype_str);
- virBufferAsprintf(buf, "<machine>%s</machine>\n", caps->machine);
+ if (caps->machine)
+ virBufferAsprintf(buf, "<machine>%s</machine>\n", caps->machine);
virBufferAsprintf(buf, "<arch>%s</arch>\n", arch_str);
if (caps->maxvcpus)
--
2.11.0
7 years, 8 months
[libvirt] [PATCH] schema: domaincaps: make machine element optional
by Roman Bogorodskiy
Commit df769041c made the 'machine' element in domaincaps
optional. Update the schema to reflect that.
---
Pushed as trivial as per
https://www.redhat.com/archives/libvir-list/2017-March/msg01239.html
docs/schemas/domaincaps.rng | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/docs/schemas/domaincaps.rng b/docs/schemas/domaincaps.rng
index 20cbc4e94..39053181e 100644
--- a/docs/schemas/domaincaps.rng
+++ b/docs/schemas/domaincaps.rng
@@ -17,9 +17,11 @@
<element name='domain'>
<text/>
</element>
- <element name='machine'>
- <text/>
- </element>
+ <optional>
+ <element name='machine'>
+ <text/>
+ </element>
+ </optional>
<element name='arch'>
<text/>
</element>
--
2.11.0
7 years, 8 months
[libvirt] [PATCH] qemu: fix build with clang
by Roman Bogorodskiy
qemuMigrationResetTLS() does not initialize 'ret' by default,
so when it jumps to 'cleanup' on error, the 'ret' variable will be
uninitialized, which clang complains about.
Set it to '-1' by default.
---
Pushed under the build-breaker rule.
src/qemu/qemu_migration.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index d91279ec6..a69e8784a 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -3815,7 +3815,7 @@ qemuMigrationResetTLS(virQEMUDriverPtr driver,
char *tlsAlias = in_tlsAlias;
char *secAlias = in_secAlias;
qemuMonitorMigrationParams migParams = { 0 };
- int ret;
+ int ret = -1;
/* If coming from a path that doesn't know whether it's been used or not,
* let's first check we need to do this. If the tls-creds doesn't exist
--
2.11.0
7 years, 8 months
[libvirt] [PATCH libvirt-glib] examples: make detail strings match event details
by Guido Günther
---
examples/event-test.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/examples/event-test.c b/examples/event-test.c
index 7c9f4ec..a204485 100644
--- a/examples/event-test.c
+++ b/examples/event-test.c
@@ -78,7 +78,7 @@ static const char *eventDetailToString(int event, int detail) {
break;
case VIR_DOMAIN_EVENT_SUSPENDED:
if (detail == VIR_DOMAIN_EVENT_SUSPENDED_PAUSED)
- ret = "Unpaused";
+ ret = "Paused";
else if (detail == VIR_DOMAIN_EVENT_SUSPENDED_MIGRATED)
ret = "Migrated";
break;
@@ -103,7 +103,7 @@ static const char *eventDetailToString(int event, int detail) {
ret = "Migrated";
break;
case VIR_DOMAIN_EVENT_STOPPED_SAVED:
- ret = "Failed";
+ ret = "Saved";
break;
case VIR_DOMAIN_EVENT_STOPPED_FAILED:
ret = "Failed";
--
2.11.0
7 years, 8 months