[PATCH] Added attach-disk parameters for network disk support
by Ryan Gahagan
Related issue: https://gitlab.com/libvirt/libvirt/-/issues/16
Added in support for the following parameters in attach-disk:
--source-name
--source-protocol
--source-host-name
--source-host-socket
--source-host-transport
Allowed for multiple hosts to be added to a single source.
Multiple hosts can be defined by providing multiple instances of
--source-host-name, followed by optional transport and socket
parameters.
Using a single host does not require a host name.
Added documentation to virsh.rst specifying usage.
Signed-off-by: Ryan Gahagan <rgahagan(a)cs.utexas.edu>
---
docs/manpages/virsh.rst | 24 +++++++-
tools/virsh-domain.c | 125 +++++++++++++++++++++++++++++++++++++---
2 files changed, 138 insertions(+), 11 deletions(-)
diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst
index bfd26e3120..60e5f5ebe4 100644
--- a/docs/manpages/virsh.rst
+++ b/docs/manpages/virsh.rst
@@ -4500,9 +4500,11 @@ attach-disk
[--current]] | [--persistent]] [--targetbus bus]
[--driver driver] [--subdriver subdriver] [--iothread iothread]
[--cache cache] [--io io] [--type type] [--alias alias]
- [--mode mode] [--sourcetype sourcetype] [--serial serial]
- [--wwn wwn] [--rawio] [--address address] [--multifunction]
- [--print-xml]
+ [--mode mode] [--sourcetype sourcetype] [--source-name name]
+ [--source-protocol protocol] [--source-host-name hostname:port]
+ [--source-host-transport transport] [--source-host-socket socket]
+ [--serial serial] [--wwn wwn] [--rawio] [--address address]
+ [--multifunction] [--print-xml]
Attach a new disk device to the domain.
*source* is path for the files and devices. *target* controls the bus or
@@ -4541,6 +4543,22 @@ ccw:cssid.ssid.devno. Virtio-ccw devices must have their cssid set to 0xfe.
*multifunction* indicates specified pci address is a multifunction pci device
address.
+If *--source-protocol* or *--source-name* is specified, then the parameters
+will be inserted into the XML that is generated for the source.
+If any of *--source-host-name*, *--source-host-transport*, or
+*--source-host-socket* are specified, then a ``<host>`` tag
+will be generated under the ``<source>`` tag containing whichever
+parameters were provided. If needed, the user can provide multiple hosts
+by providing each host with a *--source-host-name*. Each host will
+receive the host parameters which come between it and the next instance
+of *--source-host-name* or between it and the end of the command.
+If a user tries to provide multiple of the same host parameter
+for any single host, only the first one will be generated as
+part of the XML output.
+
+--source-host-name me --source-host-transport t1 --source-host-transport t2 --source-host-transport t3 --soure-host-name you
+<host transport='t1' transport='t2' transport='t3'>
+
If *--print-xml* is specified, then the XML of the disk that would be attached
is printed instead.
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 12b35c037d..609189e398 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -224,6 +224,26 @@ static const vshCmdOptDef opts_attach_disk[] = {
.flags = VSH_OFLAG_REQ | VSH_OFLAG_EMPTY_OK,
.help = N_("source of disk device")
},
+ {.name = "source-protocol",
+ .type = VSH_OT_STRING,
+ .help = N_("protocol used by disk device source")
+ },
+ {.name = "source-name",
+ .type = VSH_OT_STRING,
+ .help = N_("name of disk device source")
+ },
+ {.name = "source-host-name",
+ .type = VSH_OT_STRING,
+ .help = N_("host name for source of disk device")
+ },
+ {.name = "source-host-transport",
+ .type = VSH_OT_STRING,
+ .help = N_("host transport for source of disk device")
+ },
+ {.name = "source-host-socket",
+ .type = VSH_OT_STRING,
+ .help = N_("host socket for source of disk device")
+ },
{.name = "target",
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
@@ -558,15 +578,68 @@ static int str2DiskAddress(const char *str, struct DiskAddress *diskAddr)
return -1;
}
+static void attachDiskHostGen(virBufferPtr buf, const vshCmd *cmd)
+{
+ // Can be multiple hosts so we have to scan
+ // the cmd options to find all the host params
+ // <source tag in XML not yet closed
+ vshCmdOpt *candidate = cmd->opts;
+ char *host_name = NULL, *host_port = NULL;
+ int close_tag = 0, seen_socket = 0, seen_transport = 0;
+
+ while (candidate) {
+ // Iterate candidates to find each host-name
+ if (STREQ(candidate->def->name, "source-host-name")) {
+ // After the first host-name, we need to terminate
+ // the <host ... tag
+ // It's left open so socket and transport can be added later
+
+ // Only include the first example of socket or transport per host
+ // When a socket or transport is seen, these are set to true
+ // until the next name is encountered.
+ seen_socket = 0;
+ seen_transport = 0;
+
+ if (close_tag)
+ virBufferAddLit(buf, "/>\n");
+ else
+ close_tag = 1;
+
+ host_name = candidate->data;
+ host_port = strchr(host_name, ':');
+
+ if (!host_port) {
+ // If port isn't provided, only print name
+ virBufferAsprintf(buf, "<host name='%s'", host_name);
+ } else {
+ // If port is provided, manipulate strings and print both
+ host_name[(int)(host_port - host_name)] = '\0';
+ virBufferAsprintf(buf, "<host name='%s' port='%s'", host_name, host_port + 1);
+ }
+ } else if (!seen_socket && STREQ(candidate->def->name, "source-host-socket")) {
+ seen_socket = 1;
+ virBufferAsprintf(buf, " socket='%s'", candidate->data);
+ } else if (!seen_transport && STREQ(candidate->def->name, "source-host-transport")) {
+ seen_transport = 1;
+ virBufferAsprintf(buf, " transport='%s'", candidate->data);
+ }
+
+ candidate = candidate->next;
+ }
+ // Close final <host tag
+ virBufferAddLit(buf, "/>\n");
+}
+
static bool
cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom = NULL;
- const char *source = NULL, *target = NULL, *driver = NULL,
- *subdriver = NULL, *type = NULL, *mode = NULL,
- *iothread = NULL, *cache = NULL, *io = NULL,
- *serial = NULL, *straddr = NULL, *wwn = NULL,
- *targetbus = NULL, *alias = NULL;
+ const char *source = NULL, *source_name = NULL, *source_protocol = NULL,
+ *target = NULL, *driver = NULL, *subdriver = NULL, *type = NULL,
+ *mode = NULL, *iothread = NULL, *cache = NULL,
+ *io = NULL, *serial = NULL, *straddr = NULL,
+ *wwn = NULL, *targetbus = NULL, *alias = NULL,
+ *host_transport = NULL, *host_name = NULL, *host_socket = NULL;
struct DiskAddress diskAddr;
bool isFile = false, functionReturn = false;
int ret;
@@ -591,6 +664,8 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
flags |= VIR_DOMAIN_AFFECT_LIVE;
if (vshCommandOptStringReq(ctl, cmd, "source", &source) < 0 ||
+ vshCommandOptStringReq(ctl, cmd, "source-name", &source_name) < 0 ||
+ vshCommandOptStringReq(ctl, cmd, "source-protocol", &source_protocol) < 0 ||
vshCommandOptStringReq(ctl, cmd, "target", &target) < 0 ||
vshCommandOptStringReq(ctl, cmd, "driver", &driver) < 0 ||
vshCommandOptStringReq(ctl, cmd, "subdriver", &subdriver) < 0 ||
@@ -604,7 +679,10 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
vshCommandOptStringReq(ctl, cmd, "address", &straddr) < 0 ||
vshCommandOptStringReq(ctl, cmd, "targetbus", &targetbus) < 0 ||
vshCommandOptStringReq(ctl, cmd, "alias", &alias) < 0 ||
- vshCommandOptStringReq(ctl, cmd, "sourcetype", &stype) < 0)
+ vshCommandOptStringReq(ctl, cmd, "sourcetype", &stype) < 0 ||
+ vshCommandOptStringReq(ctl, cmd, "source-host-name", (const char **) &host_name) < 0 ||
+ vshCommandOptStringReq(ctl, cmd, "source-host-transport", &host_transport) < 0 ||
+ vshCommandOptStringReq(ctl, cmd, "source-host-socket", &host_socket) < 0)
goto cleanup;
if (!stype) {
@@ -659,9 +737,40 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
virBufferAddLit(&buf, "/>\n");
}
- if (source)
- virBufferAsprintf(&buf, "<source %s='%s'/>\n",
+ if (source || source_protocol || source_name ||
+ host_name || host_transport || host_socket) {
+ virBufferAddLit(&buf, "<source");
+
+ if (source)
+ virBufferAsprintf(&buf, " %s='%s'",
isFile ? "file" : "dev", source);
+ if (source_protocol)
+ virBufferAsprintf(&buf, " protocol='%s'", source_protocol);
+ if (source_name)
+ virBufferAsprintf(&buf, " name='%s'", source_name);
+
+ if (!(host_name || host_transport || host_socket)) {
+ // Close source if no host is provided
+ virBufferAddLit(&buf, "/>\n");
+ } else if (!host_name) {
+ // If no host name is provided but there is a host,
+ // we have a single host with params
+ virBufferAddLit(&buf, ">\n<host");
+
+ if (host_transport)
+ virBufferAsprintf(&buf, " transport='%s'", host_transport);
+ if (host_socket)
+ virBufferAsprintf(&buf, " socket='%s'", host_socket);
+
+ virBufferAddLit(&buf, "/>\n</source>\n");
+ } else {
+ // May have multiple hosts, use helper method
+ virBufferAddLit(&buf, ">\n");
+ attachDiskHostGen(&buf, cmd);
+ virBufferAddLit(&buf, "</source>\n");
+ }
+ }
+
virBufferAsprintf(&buf, "<target dev='%s'", target);
if (targetbus)
virBufferAsprintf(&buf, " bus='%s'", targetbus);
--
2.29.0
4 years
[PATCH 0/7] hyperv: some memory and scheduler APIs
by Matt Coleman
Here's a GitLab merge request, if you'd prefer to review it there:
https://gitlab.com/iammattcoleman/libvirt/-/merge_requests/9
Matt Coleman (7):
hyperv: implement domainGetMaxMemory
hyperv: move hypervDomainSetMemory and hypervDomainSetMemoryFlags
hyperv: implement domainSetMaxMemory
hyperv: add hypervMsvmVSMSModifyResourceSettings
hyperv: refactor hypervDomainSetMemoryProperty
hyperv: implement domainGetScheduler*
news: some memory and scheduler Hyper-V APIs
NEWS.rst | 7 +
src/hyperv/hyperv_driver.c | 253 ++++++++++++++++++++++++++-----------
src/hyperv/hyperv_wmi.c | 37 ++++++
src/hyperv/hyperv_wmi.h | 8 ++
4 files changed, 233 insertions(+), 72 deletions(-)
--
2.27.0
4 years
[PATCH] selinux label: restore all labels when some labels fail to set
by Jin Yan
When migration fails, qemuMigrationDstPrepareAny will call qemuProcessStop
to restore labels only after all labels are successfully set. If some labels
fail to set, the labels that have been set will not be restore.
Signed-off-by: Jin Yan <jinyan12(a)huawei.com>
---
src/qemu/qemu_security.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_security.c b/src/qemu/qemu_security.c
index 3bda96272c..e4d5e13516 100644
--- a/src/qemu/qemu_security.c
+++ b/src/qemu/qemu_security.c
@@ -51,13 +51,20 @@ qemuSecuritySetAllLabel(virQEMUDriverPtr driver,
incomingPath,
priv->chardevStdioLogd,
migrated) < 0)
- goto cleanup;
+ goto restorelabel;
if (virSecurityManagerTransactionCommit(driver->securityManager,
pid, priv->rememberOwner) < 0)
- goto cleanup;
+ goto restorelabel;
ret = 0;
+
+ restorelabel:
+ virSecurityManagerRestoreAllLabel(driver->securityManager,
+ vm->def,
+ migrated,
+ priv->chardevStdioLogd);
+
cleanup:
virSecurityManagerTransactionAbort(driver->securityManager);
return ret;
--
2.23.0
4 years
[libvirt PATCH] qemu: Do not require TSC frequency to strictly match host
by Jiri Denemark
Some CPUs provide a way to read exact TSC frequency, while measuring it
is required on other CPUs. However, measuring is never exact and the
result may slightly differ across reboots. For this reason both Linux
kernel and QEMU recently started allowing for guests TSC frequency to
fall into +/- 250 ppm tolerance interval around the host TSC frequency.
Let's do the same to avoid unnecessary failures (esp. during migration)
in case the host frequency does not exactly match the frequency
configured in a domain XML.
https://bugzilla.redhat.com/show_bug.cgi?id=1839095
Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
src/qemu/qemu_process.c | 35 ++++++++++++++++++++++++++---------
1 file changed, 26 insertions(+), 9 deletions(-)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 0a36b49c85..7f56ddf114 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -5358,12 +5358,18 @@ qemuProcessStartValidateDisks(virDomainObjPtr vm,
}
+/* 250 parts per million (ppm) is a half of NTP threshold */
+#define TSC_TOLERANCE 250
+
static int
qemuProcessStartValidateTSC(virQEMUDriverPtr driver,
virDomainObjPtr vm)
{
size_t i;
unsigned long long freq = 0;
+ unsigned long long tolerance;
+ unsigned long long minFreq;
+ unsigned long long maxFreq;
virHostCPUTscInfoPtr tsc;
g_autoptr(virCPUDef) cpu = NULL;
@@ -5389,23 +5395,34 @@ qemuProcessStartValidateTSC(virQEMUDriverPtr driver,
}
tsc = cpu->tsc;
- VIR_DEBUG("Host TSC frequency %llu Hz, scaling %s",
- tsc->frequency, virTristateBoolTypeToString(tsc->scaling));
+ tolerance = tsc->frequency * TSC_TOLERANCE / 1000000;
+ minFreq = tsc->frequency - tolerance;
+ maxFreq = tsc->frequency + tolerance;
+
+ VIR_DEBUG("Host TSC frequency %llu Hz, scaling %s, tolerance +/- %llu Hz",
+ tsc->frequency, virTristateBoolTypeToString(tsc->scaling),
+ tolerance);
+
+ if (freq > minFreq && freq < maxFreq) {
+ VIR_DEBUG("Requested TSC frequency is within tolerance interval");
+ return 0;
+ }
- if (freq == tsc->frequency || tsc->scaling == VIR_TRISTATE_BOOL_YES)
+ if (tsc->scaling == VIR_TRISTATE_BOOL_YES)
return 0;
if (tsc->scaling == VIR_TRISTATE_BOOL_ABSENT) {
- VIR_DEBUG("TSC frequencies do not match and scaling support is "
- "unknown, QEMU will try and possibly fail later");
+ VIR_DEBUG("Requested TSC frequency falls outside tolerance range and "
+ "scaling support is unknown, QEMU will try and possibly "
+ "fail later");
return 0;
}
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("Requested TSC frequency %llu Hz does not match "
- "host (%llu Hz) and TSC scaling is not supported "
- "by the host CPU"),
- freq, tsc->frequency);
+ _("Requested TSC frequency %llu Hz is outside tolerance "
+ "range ([%llu, %llu] Hz) around host frequency %llu Hz "
+ "and TSC scaling is not supported by the host CPU"),
+ freq, minFreq, maxFreq, tsc->frequency);
return -1;
}
--
2.29.2
4 years
[PATCH] Added attach-disk parameters for network disk support
by Ryan Gahagan
Related issue: https://gitlab.com/libvirt/libvirt/-/issues/16
Added in support for the following parameters in attach-disk:
--source-name
--source-protocol
--source-host-name
--source-host-socket
--source-host-transport
Allowed for multiple hosts to be added to a single source.
Multiple hosts can be defined by providing multiple instances of
--source-host-name, followed by optional transport and socket
parameters.
Using a single host does not require a host name.
Added documentation to virsh.rst specifying usage.
Signed-off-by: Ryan Gahagan <rgahagan(a)cs.utexas.edu>
---
docs/manpages/virsh.rst | 24 +++++++-
tools/virsh-domain.c | 125 +++++++++++++++++++++++++++++++++++++---
2 files changed, 138 insertions(+), 11 deletions(-)
diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst
index bfd26e3120..60e5f5ebe4 100644
--- a/docs/manpages/virsh.rst
+++ b/docs/manpages/virsh.rst
@@ -4500,9 +4500,11 @@ attach-disk
[--current]] | [--persistent]] [--targetbus bus]
[--driver driver] [--subdriver subdriver] [--iothread iothread]
[--cache cache] [--io io] [--type type] [--alias alias]
- [--mode mode] [--sourcetype sourcetype] [--serial serial]
- [--wwn wwn] [--rawio] [--address address] [--multifunction]
- [--print-xml]
+ [--mode mode] [--sourcetype sourcetype] [--source-name name]
+ [--source-protocol protocol] [--source-host-name hostname:port]
+ [--source-host-transport transport] [--source-host-socket socket]
+ [--serial serial] [--wwn wwn] [--rawio] [--address address]
+ [--multifunction] [--print-xml]
Attach a new disk device to the domain.
*source* is path for the files and devices. *target* controls the bus or
@@ -4541,6 +4543,22 @@ ccw:cssid.ssid.devno. Virtio-ccw devices must have their cssid set to 0xfe.
*multifunction* indicates specified pci address is a multifunction pci device
address.
+If *--source-protocol* or *--source-name* is specified, then the parameters
+will be inserted into the XML that is generated for the source.
+If any of *--source-host-name*, *--source-host-transport*, or
+*--source-host-socket* are specified, then a ``<host>`` tag
+will be generated under the ``<source>`` tag containing whichever
+parameters were provided. If needed, the user can provide multiple hosts
+by providing each host with a *--source-host-name*. Each host will
+receive the host parameters which come between it and the next instance
+of *--source-host-name* or between it and the end of the command.
+If a user tries to provide multiple of the same host parameter
+for any single host, only the first one will be generated as
+part of the XML output.
+
+--source-host-name me --source-host-transport t1 --source-host-transport t2 --source-host-transport t3 --soure-host-name you
+<host transport='t1' transport='t2' transport='t3'>
+
If *--print-xml* is specified, then the XML of the disk that would be attached
is printed instead.
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 12b35c037d..469665f0f0 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -224,6 +224,26 @@ static const vshCmdOptDef opts_attach_disk[] = {
.flags = VSH_OFLAG_REQ | VSH_OFLAG_EMPTY_OK,
.help = N_("source of disk device")
},
+ {.name = "source-protocol",
+ .type = VSH_OT_STRING,
+ .help = N_("protocol used by disk device source")
+ },
+ {.name = "source-name",
+ .type = VSH_OT_STRING,
+ .help = N_("name of disk device source")
+ },
+ {.name = "source-host-name",
+ .type = VSH_OT_STRING,
+ .help = N_("host name for source of disk device")
+ },
+ {.name = "source-host-transport",
+ .type = VSH_OT_STRING,
+ .help = N_("host transport for source of disk device")
+ },
+ {.name = "source-host-socket",
+ .type = VSH_OT_STRING,
+ .help = N_("host socket for source of disk device")
+ },
{.name = "target",
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
@@ -558,15 +578,68 @@ static int str2DiskAddress(const char *str, struct DiskAddress *diskAddr)
return -1;
}
+static void attachDiskHostGen(virBufferPtr buf, const vshCmd *cmd)
+{
+ // Can be multiple hosts so we have to scan
+ // the cmd options to find all the host params
+ // <source tag in XML not yet closed
+ vshCmdOpt *candidate = cmd->opts;
+ char *host_name = NULL, *host_port = NULL;
+ int close_tag = 0, seen_socket, seen_transport;
+
+ while (candidate) {
+ // Iterate candidates to find each host-name
+ if (STREQ(candidate->def->name, "source-host-name")) {
+ // After the first host-name, we need to terminate
+ // the <host ... tag
+ // It's left open so socket and transport can be added later
+
+ // Only include the first example of socket or transport per host
+ // When a socket or transport is seen, these are set to true
+ // until the next name is encountered.
+ seen_socket = 0;
+ seen_transport = 0;
+
+ if (close_tag)
+ virBufferAddLit(buf, "/>\n");
+ else
+ close_tag = 1;
+
+ host_name = candidate->data;
+ host_port = strchr(host_name, ':');
+
+ if (!host_port) {
+ // If port isn't provided, only print name
+ virBufferAsprintf(buf, "<host name='%s'", host_name);
+ } else {
+ // If port is provided, manipulate strings and print both
+ host_name[(int)(host_port - host_name)] = '\0';
+ virBufferAsprintf(buf, "<host name='%s' port='%s'", host_name, host_port + 1);
+ }
+ } else if (!seen_socket && STREQ(candidate->def->name, "source-host-socket")) {
+ seen_socket = 1;
+ virBufferAsprintf(buf, " socket='%s'", candidate->data);
+ } else if (!seen_transport && STREQ(candidate->def->name, "source-host-transport")) {
+ seen_transport = 1;
+ virBufferAsprintf(buf, " transport='%s'", candidate->data);
+ }
+
+ candidate = candidate->next;
+ }
+ // Close final <host tag
+ virBufferAddLit(buf, "/>\n");
+}
+
static bool
cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
{
virDomainPtr dom = NULL;
- const char *source = NULL, *target = NULL, *driver = NULL,
- *subdriver = NULL, *type = NULL, *mode = NULL,
- *iothread = NULL, *cache = NULL, *io = NULL,
- *serial = NULL, *straddr = NULL, *wwn = NULL,
- *targetbus = NULL, *alias = NULL;
+ const char *source = NULL, *source_name = NULL, *source_protocol = NULL,
+ *target = NULL, *driver = NULL, *subdriver = NULL, *type = NULL,
+ *mode = NULL, *iothread = NULL, *cache = NULL,
+ *io = NULL, *serial = NULL, *straddr = NULL,
+ *wwn = NULL, *targetbus = NULL, *alias = NULL,
+ *host_transport = NULL, *host_name = NULL, *host_socket = NULL;
struct DiskAddress diskAddr;
bool isFile = false, functionReturn = false;
int ret;
@@ -591,6 +664,8 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
flags |= VIR_DOMAIN_AFFECT_LIVE;
if (vshCommandOptStringReq(ctl, cmd, "source", &source) < 0 ||
+ vshCommandOptStringReq(ctl, cmd, "source-name", &source_name) < 0 ||
+ vshCommandOptStringReq(ctl, cmd, "source-protocol", &source_protocol) < 0 ||
vshCommandOptStringReq(ctl, cmd, "target", &target) < 0 ||
vshCommandOptStringReq(ctl, cmd, "driver", &driver) < 0 ||
vshCommandOptStringReq(ctl, cmd, "subdriver", &subdriver) < 0 ||
@@ -604,7 +679,10 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
vshCommandOptStringReq(ctl, cmd, "address", &straddr) < 0 ||
vshCommandOptStringReq(ctl, cmd, "targetbus", &targetbus) < 0 ||
vshCommandOptStringReq(ctl, cmd, "alias", &alias) < 0 ||
- vshCommandOptStringReq(ctl, cmd, "sourcetype", &stype) < 0)
+ vshCommandOptStringReq(ctl, cmd, "sourcetype", &stype) < 0 ||
+ vshCommandOptStringReq(ctl, cmd, "source-host-name", (const char **) &host_name) < 0 ||
+ vshCommandOptStringReq(ctl, cmd, "source-host-transport", &host_transport) < 0 ||
+ vshCommandOptStringReq(ctl, cmd, "source-host-socket", &host_socket) < 0)
goto cleanup;
if (!stype) {
@@ -659,9 +737,40 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
virBufferAddLit(&buf, "/>\n");
}
- if (source)
- virBufferAsprintf(&buf, "<source %s='%s'/>\n",
+ if (source || source_protocol || source_name ||
+ host_name || host_transport || host_socket) {
+ virBufferAddLit(&buf, "<source");
+
+ if (source)
+ virBufferAsprintf(&buf, " %s='%s'",
isFile ? "file" : "dev", source);
+ if (source_protocol)
+ virBufferAsprintf(&buf, " protocol='%s'", source_protocol);
+ if (source_name)
+ virBufferAsprintf(&buf, " name='%s'", source_name);
+
+ if (!(host_name || host_transport || host_socket)) {
+ // Close source if no host is provided
+ virBufferAddLit(&buf, "/>\n");
+ } else if (!host_name) {
+ // If no host name is provided but there is a host,
+ // we have a single host with params
+ virBufferAddLit(&buf, ">\n<host");
+
+ if (host_transport)
+ virBufferAsprintf(&buf, " transport='%s'", host_transport);
+ if (host_socket)
+ virBufferAsprintf(&buf, " socket='%s'", host_socket);
+
+ virBufferAddLit(&buf, "/>\n</source>\n");
+ } else {
+ // May have multiple hosts, use helper method
+ virBufferAddLit(&buf, ">\n");
+ attachDiskHostGen(&buf, cmd);
+ virBufferAddLit(&buf, "</source>\n");
+ }
+ }
+
virBufferAsprintf(&buf, "<target dev='%s'", target);
if (targetbus)
virBufferAsprintf(&buf, " bus='%s'", targetbus);
--
2.29.0
4 years
[libvirt PATCH] conf: Use unsigned long long for timer frequency
by Jiri Denemark
Although the code in qemuProcessStartValidateTSC works as if the
timer frequency was already unsigned long long (by using an appropriate
temporary variable), the virDomainTimerDef structure actually defines
frequency as unsigned long, which is not guaranteed to be 64b.
Fixes support for frequencies higher than 2^32 - 1 on 32b systems.
Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
src/conf/domain_conf.c | 6 +++---
src/conf/domain_conf.h | 2 +-
src/qemu/qemu_command.c | 2 +-
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index a3ca332279..9199771dc0 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -14053,7 +14053,7 @@ virDomainTimerDefParseXML(xmlNodePtr node,
}
}
- ret = virXPathULong("string(./@frequency)", ctxt, &def->frequency);
+ ret = virXPathULongLong("string(./@frequency)", ctxt, &def->frequency);
if (ret == -1) {
def->frequency = 0;
} else if (ret < 0) {
@@ -22851,7 +22851,7 @@ virDomainTimerDefCheckABIStability(virDomainTimerDefPtr src,
if (src->name == VIR_DOMAIN_TIMER_NAME_TSC) {
if (src->frequency != dst->frequency) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("Target TSC frequency %lu does not match source %lu"),
+ _("Target TSC frequency %llu does not match source %llu"),
dst->frequency, src->frequency);
return false;
}
@@ -28166,7 +28166,7 @@ virDomainTimerDefFormat(virBufferPtr buf,
if (def->name == VIR_DOMAIN_TIMER_NAME_TSC) {
if (def->frequency > 0)
- virBufferAsprintf(buf, " frequency='%lu'", def->frequency);
+ virBufferAsprintf(buf, " frequency='%llu'", def->frequency);
if (def->mode != -1) {
const char *mode
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 77656c8ae3..16c050a3ea 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2207,7 +2207,7 @@ struct _virDomainTimerDef {
int track; /* boot|guest|wall */
/* frequency & mode are only valid for name='tsc' */
- unsigned long frequency; /* in Hz, unspecified = 0 */
+ unsigned long long frequency; /* in Hz, unspecified = 0 */
int mode; /* auto|native|emulate|paravirt */
};
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index b0c2a5efb5..0fecb9f6e7 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -6357,7 +6357,7 @@ qemuBuildCpuCommandLine(virCommandPtr cmd,
break;
case VIR_DOMAIN_TIMER_NAME_TSC:
if (timer->frequency > 0)
- virBufferAsprintf(&buf, ",tsc-frequency=%lu", timer->frequency);
+ virBufferAsprintf(&buf, ",tsc-frequency=%llu", timer->frequency);
break;
case VIR_DOMAIN_TIMER_NAME_ARMVTIMER:
switch (timer->tickpolicy) {
--
2.29.2
4 years
[libvirt PATCH] util: fix insert/instead documentation mixup
by Jonathon Jongsma
Signed-off-by: Jonathon Jongsma <jjongsma(a)redhat.com>
---
src/util/virhash.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/util/virhash.c b/src/util/virhash.c
index 5d5b6389b5..d105820bfa 100644
--- a/src/util/virhash.c
+++ b/src/util/virhash.c
@@ -147,8 +147,8 @@ virHashFree(GHashTable *table)
* Add the @userdata to the hash @table. This can later be retrieved
* by using @name. Duplicate entries generate errors.
*
- * Deprecated: Consider using g_hash_table_insert insert. Note that
- * g_hash_table_instead doesn't fail if entry exists. Also note that
+ * Deprecated: Consider using g_hash_table_insert instead. Note that
+ * g_hash_table_insert doesn't fail if entry exists. Also note that
* g_hash_table_insert doesn't copy the key.
*
* Returns 0 the addition succeeded and -1 in case of error.
--
2.26.2
4 years
[PATCH v3 0/3] Support mdev_types on CSS devices
by Boris Fiuczynski
All refactoring patches of this series in v1 were accepted except for
the patch enabling the mdev_types support on CSS devices.
v2 added one more refactoring patch in docs before the already
sent enablement patch follows again.
v3 adds another tiny renaming patch and changes some references in the
docs.
Boris Fiuczynski (3):
docs: refactor mdev_types into new paragraph
docs: rename reference MDEVCap into MDEVTypesCapPCI
node_device: detecting mdev_types capability on CSS devices
docs/drvnodedev.html.in | 4 +-
docs/formatnode.html.in | 86 +++++++++++------
docs/schemas/nodedev.rng | 4 +
src/conf/node_device_conf.c | 92 ++++++++++++++++++-
src/conf/node_device_conf.h | 11 +++
src/conf/virnodedeviceobj.c | 7 +-
src/libvirt_private.syms | 1 +
src/node_device/node_device_udev.c | 3 +
.../css_0_0_fffe_mdev_types.xml | 17 ++++
tests/nodedevxml2xmltest.c | 1 +
10 files changed, 191 insertions(+), 35 deletions(-)
create mode 100644 tests/nodedevschemadata/css_0_0_fffe_mdev_types.xml
--
2.26.2
4 years
[libvirt PATCH v2 00/16] Add support for persistent mediated devices
by Jonathon Jongsma
This patch series follows the previously-merged series which added support for
transient mediated devices. This series expands mdev support to include
persistent device definitions. Again, it relies on mdevctl as the backend.
It follows the common libvirt pattern of APIs by adding the following new APIs
for node devices:
- virNodeDeviceDefineXML() - defines a persistent device
- virNodeDeviceUndefine() - undefines a persistent device
- virNodeDeviceCreate() - starts a previously-defined device
It also adds virsh commands mapping to these new APIs: nodedev-define,
nodedev-undefine, and nodedev-start.
The method of staying up-to-date with devices defined by mdevctl is currently=
a
little bit crude due to the fact that mdevctl does not emit any events when n=
ew
devices are added or removed. As a workaround, we create a file monitor for t=
he
mdevctl config directory and re-query mdevctl when we detect changes within
that directory. In the future, mdevctl may introduce a more elegant solution.
Changes in v2:
- rebase to latest git master
Jonathon Jongsma (16):
tests: remove extra trailing semicolon
nodedev: introduce concept of 'active' node devices
nodedev: Add ability to filter by active state
virsh: Add --active, --inactive, --all to nodedev-list
nodedev: add ability to list and parse defined mdevs
nodedev: add STOPPED/STARTED lifecycle events
nodedev: add mdevctl devices to node device list
nodedev: handle mdevs that disappear from mdevctl
nodedev: add an mdevctl thread
api: add virNodeDeviceDefineXML()
virsh: add nodedev-define command
api: add virNodeDeviceUndefine()
virsh: Factor out function to find node device
virsh: add nodedev-undefine command
api: add virNodeDeviceCreate()
virsh: add "nodedev-start" command
examples/c/misc/event-test.c | 4 +
include/libvirt/libvirt-nodedev.h | 19 +-
src/conf/node_device_conf.h | 9 +
src/conf/virnodedeviceobj.c | 24 +
src/conf/virnodedeviceobj.h | 7 +
src/driver-nodedev.h | 14 +
src/libvirt-nodedev.c | 115 ++++
src/libvirt_private.syms | 2 +
src/libvirt_public.syms | 6 +
src/node_device/node_device_driver.c | 525 +++++++++++++++++-
src/node_device/node_device_driver.h | 38 ++
src/node_device/node_device_udev.c | 275 ++++++++-
src/remote/remote_driver.c | 3 +
src/remote/remote_protocol.x | 40 +-
src/remote_protocol-structs | 16 +
src/rpc/gendispatch.pl | 1 +
...19_36ea_4111_8f0a_8c9a70e21366-define.argv | 1 +
...19_36ea_4111_8f0a_8c9a70e21366-define.json | 1 +
...39_495e_4243_ad9f_beb3f14c23d9-define.argv | 1 +
...39_495e_4243_ad9f_beb3f14c23d9-define.json | 1 +
...16_1ca8_49ac_b176_871d16c13076-define.argv | 1 +
...16_1ca8_49ac_b176_871d16c13076-define.json | 1 +
tests/nodedevmdevctldata/mdevctl-create.argv | 1 +
.../mdevctl-list-defined.argv | 1 +
.../mdevctl-list-multiple-parents.json | 59 ++
.../mdevctl-list-multiple-parents.out.xml | 39 ++
.../mdevctl-list-multiple.json | 59 ++
.../mdevctl-list-multiple.out.xml | 39 ++
.../mdevctl-list-single-noattr.json | 11 +
.../mdevctl-list-single-noattr.out.xml | 8 +
.../mdevctl-list-single.json | 31 ++
.../mdevctl-list-single.out.xml | 14 +
.../nodedevmdevctldata/mdevctl-undefine.argv | 1 +
tests/nodedevmdevctltest.c | 227 +++++++-
tools/virsh-nodedev.c | 281 ++++++++--
35 files changed, 1787 insertions(+), 88 deletions(-)
create mode 100644 tests/nodedevmdevctldata/mdev_d069d019_36ea_4111_8f0a_8c9=
a70e21366-define.argv
create mode 100644 tests/nodedevmdevctldata/mdev_d069d019_36ea_4111_8f0a_8c9=
a70e21366-define.json
create mode 100644 tests/nodedevmdevctldata/mdev_d2441d39_495e_4243_ad9f_beb=
3f14c23d9-define.argv
create mode 100644 tests/nodedevmdevctldata/mdev_d2441d39_495e_4243_ad9f_beb=
3f14c23d9-define.json
create mode 100644 tests/nodedevmdevctldata/mdev_fedc4916_1ca8_49ac_b176_871=
d16c13076-define.argv
create mode 100644 tests/nodedevmdevctldata/mdev_fedc4916_1ca8_49ac_b176_871=
d16c13076-define.json
create mode 100644 tests/nodedevmdevctldata/mdevctl-create.argv
create mode 100644 tests/nodedevmdevctldata/mdevctl-list-defined.argv
create mode 100644 tests/nodedevmdevctldata/mdevctl-list-multiple-parents.js=
on
create mode 100644 tests/nodedevmdevctldata/mdevctl-list-multiple-parents.ou=
t.xml
create mode 100644 tests/nodedevmdevctldata/mdevctl-list-multiple.json
create mode 100644 tests/nodedevmdevctldata/mdevctl-list-multiple.out.xml
create mode 100644 tests/nodedevmdevctldata/mdevctl-list-single-noattr.json
create mode 100644 tests/nodedevmdevctldata/mdevctl-list-single-noattr.out.x=
ml
create mode 100644 tests/nodedevmdevctldata/mdevctl-list-single.json
create mode 100644 tests/nodedevmdevctldata/mdevctl-list-single.out.xml
create mode 100644 tests/nodedevmdevctldata/mdevctl-undefine.argv
--=20
2.26.2
4 years
[libvirt PATCH] schema: Add support for high TSC frequency
by Jiri Denemark
The unsignedInt XML schema type allows for values up to 2^32 - 1, i.e.,
using 4294967296 or greater TSC frequency would fail schema validation.
Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
docs/schemas/domaincommon.rng | 2 +-
.../cpu-tsc-high-frequency.x86_64-latest.args | 38 +++++++++++++++++++
.../cpu-tsc-high-frequency.xml | 35 +++++++++++++++++
tests/qemuxml2argvtest.c | 1 +
4 files changed, 75 insertions(+), 1 deletion(-)
create mode 100644 tests/qemuxml2argvdata/cpu-tsc-high-frequency.x86_64-latest.args
create mode 100644 tests/qemuxml2argvdata/cpu-tsc-high-frequency.xml
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 97fa873977..e0d09f9c03 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -1235,7 +1235,7 @@
</optional>
<optional>
<attribute name="frequency">
- <ref name="unsignedInt"/>
+ <ref name="unsignedLong"/>
</attribute>
</optional>
<optional>
diff --git a/tests/qemuxml2argvdata/cpu-tsc-high-frequency.x86_64-latest.args b/tests/qemuxml2argvdata/cpu-tsc-high-frequency.x86_64-latest.args
new file mode 100644
index 0000000000..16a4282ab1
--- /dev/null
+++ b/tests/qemuxml2argvdata/cpu-tsc-high-frequency.x86_64-latest.args
@@ -0,0 +1,38 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/tmp/lib/domain--1-QEMUGuest1 \
+USER=test \
+LOGNAME=test \
+XDG_DATA_HOME=/tmp/lib/domain--1-QEMUGuest1/.local/share \
+XDG_CACHE_HOME=/tmp/lib/domain--1-QEMUGuest1/.cache \
+XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-system-x86_64 \
+-name guest=QEMUGuest1,debug-threads=on \
+-S \
+-object secret,id=masterKey0,format=raw,\
+file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
+-machine pc,accel=kvm,usb=off,dump-guest-core=off,memory-backend=pc.ram \
+-cpu EPYC-Rome,x2apic=on,tsc-deadline=on,hypervisor=on,tsc-adjust=on,stibp=on,\
+arch-capabilities=on,ssbd=on,xsaves=on,cmp-legacy=on,amd-ssbd=on,virt-ssbd=on,\
+rdctl-no=on,skip-l1dfl-vmentry=on,mds-no=on,pschange-mc-no=on,invtsc=on,\
+tsc-frequency=4567890000 \
+-m 214 \
+-object memory-backend-ram,id=pc.ram,size=224395264 \
+-overcommit mem-lock=off \
+-smp 1,sockets=1,cores=1,threads=1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-display none \
+-no-user-config \
+-nodefaults \
+-chardev socket,id=charmonitor,fd=1729,server,nowait \
+-mon chardev=charmonitor,id=monitor,mode=control \
+-rtc base=utc \
+-no-shutdown \
+-no-acpi \
+-boot strict=on \
+-device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \
+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2 \
+-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,\
+resourcecontrol=deny \
+-msg timestamp=on
diff --git a/tests/qemuxml2argvdata/cpu-tsc-high-frequency.xml b/tests/qemuxml2argvdata/cpu-tsc-high-frequency.xml
new file mode 100644
index 0000000000..afaef6e8e5
--- /dev/null
+++ b/tests/qemuxml2argvdata/cpu-tsc-high-frequency.xml
@@ -0,0 +1,35 @@
+<domain type='kvm'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <title>A description of the test machine.</title>
+ <description>
+ A test of qemu's minimal configuration.
+ This test also tests the description and title elements.
+ </description>
+ <memory unit='KiB'>219100</memory>
+ <currentMemory unit='KiB'>219100</currentMemory>
+ <vcpu placement='static'>1</vcpu>
+ <os>
+ <type arch='x86_64' machine='pc'>hvm</type>
+ <boot dev='hd'/>
+ </os>
+ <cpu mode='host-model'>
+ <model fallback='allow'/>
+ <feature policy='require' name='invtsc'/>
+ </cpu>
+ <clock offset='utc'>
+ <timer name='tsc' frequency='4567890000'/>
+ </clock>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <emulator>/usr/bin/qemu-system-x86_64</emulator>
+ <controller type='usb' index='0'/>
+ <controller type='ide' index='0'/>
+ <controller type='pci' index='0' model='pci-root'/>
+ <input type='mouse' bus='ps2'/>
+ <input type='keyboard' bus='ps2'/>
+ <memballoon model='virtio'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index ec33134a97..174294c0f1 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1953,6 +1953,7 @@ mymain(void)
DO_TEST_CAPS_VER("cpu-host-model-cmt", "4.0.0");
DO_TEST("cpu-tsc-frequency", QEMU_CAPS_KVM);
DO_TEST_CAPS_VER("cpu-tsc-frequency", "4.0.0");
+ DO_TEST_CAPS_LATEST("cpu-tsc-high-frequency");
DO_TEST_CAPS_VER("cpu-translation", "4.0.0");
DO_TEST_CAPS_LATEST("cpu-translation");
qemuTestSetHostCPU(&driver, driver.hostarch, NULL);
--
2.29.2
4 years