[PATCH v2 00/13] Hyper-V serial ports, NICs, and screeshots
by Matt Coleman
This patchset makes the following changes to the Hyper-V driver:
* enable XML parsing and creation of serial ports and NICs
* implement several networking APIs
* implement screenshots
Changes since v1:
* simplified hypervDomainDefParseSerial based on Michal's feedback
* enabled the use of g_autoptr for virDomainNetDef
* use g_autoptr for ndef in hypervDomainDefParseEthernetAdapter to fix
the memory leaks that Michal spotted
Matt Coleman (13):
hyperv: XML parsing of serial ports
hyperv: add support for creating serial devices
domain_conf: enable use of g_autofree for virDomainNetDef
hyperv: XML parsing of Ethernet adapters
hyperv: add support for creating network adapters
hyperv: implement connectListAllNetworks and connectNumOfNetworks
hyperv: implement networkLookupByName and networkLookupByUUID
hyperv: implement connectNumOfDefinedNetworks and
connectListDefinedNetworks
hyperv: implement networkGetAutostart, networkIsActive, and
networkIsPersistent
hyperv: implement networkGetXMLDesc
hyperv: implement domainScreenshot
hyperv: provide a more detailed error message for WSMan faults
news: implement new Hyper-V APIs
NEWS.rst | 12 +
po/POTFILES.in | 1 +
src/conf/domain_conf.h | 1 +
src/hyperv/hyperv_driver.c | 611 ++++++++++++++++++++++++++
src/hyperv/hyperv_network_driver.c | 242 ++++++++++
src/hyperv/hyperv_network_driver.h | 26 ++
src/hyperv/hyperv_wmi.c | 45 +-
src/hyperv/hyperv_wmi.h | 12 +
src/hyperv/hyperv_wmi_classes.h | 36 ++
src/hyperv/hyperv_wmi_generator.input | 309 +++++++++++++
src/hyperv/meson.build | 1 +
11 files changed, 1293 insertions(+), 3 deletions(-)
create mode 100644 src/hyperv/hyperv_network_driver.c
create mode 100644 src/hyperv/hyperv_network_driver.h
--
2.30.0
3 years, 10 months
[PATCH] virsh: Simplify @flags handing in cmdSetmem() and cmdSetmaxmem()
by Michal Privoznik
What code tries to achieve is that if no flags were provided to
either 'setmem' or 'setmaxmem' commands then the old (no flags)
API is called to be able to communicate with older daemons.
Well, the code can be simplified a bit.
Note that with this change the old no flag version of APIs is
used more often. Previously if --current argument was given it
resulted in *Flags() version to be called even though it is not
necessary - VIR_DOMAIN_AFFECT_CURRENT is implied.
Therefore, this change in fact allows virsh to talk with broader
set of daemons.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
tools/virsh-domain.c | 14 ++++----------
1 file changed, 4 insertions(+), 10 deletions(-)
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 2bb136333f..9746117bdb 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -9018,9 +9018,6 @@ cmdSetmem(vshControl *ctl, const vshCmd *cmd)
flags |= VIR_DOMAIN_AFFECT_CONFIG;
if (live)
flags |= VIR_DOMAIN_AFFECT_LIVE;
- /* none of the options were specified */
- if (!current && !live && !config)
- flags = -1;
if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
return false;
@@ -9037,7 +9034,7 @@ cmdSetmem(vshControl *ctl, const vshCmd *cmd)
}
kibibytes = VIR_DIV_UP(bytes, 1024);
- if (flags == -1) {
+ if (flags == 0) {
if (virDomainSetMemory(dom, kibibytes) != 0)
ret = false;
} else {
@@ -9090,7 +9087,7 @@ cmdSetmaxmem(vshControl *ctl, const vshCmd *cmd)
bool config = vshCommandOptBool(cmd, "config");
bool live = vshCommandOptBool(cmd, "live");
bool current = vshCommandOptBool(cmd, "current");
- unsigned int flags = VIR_DOMAIN_AFFECT_CURRENT | VIR_DOMAIN_MEM_MAXIMUM;
+ unsigned int flags = VIR_DOMAIN_AFFECT_CURRENT;
VSH_EXCLUSIVE_OPTIONS_VAR(current, live);
VSH_EXCLUSIVE_OPTIONS_VAR(current, config);
@@ -9099,9 +9096,6 @@ cmdSetmaxmem(vshControl *ctl, const vshCmd *cmd)
flags |= VIR_DOMAIN_AFFECT_CONFIG;
if (live)
flags |= VIR_DOMAIN_AFFECT_LIVE;
- /* none of the options were specified */
- if (!current && !live && !config)
- flags = -1;
if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
return false;
@@ -9118,13 +9112,13 @@ cmdSetmaxmem(vshControl *ctl, const vshCmd *cmd)
}
kibibytes = VIR_DIV_UP(bytes, 1024);
- if (flags == -1) {
+ if (flags == 0) {
if (virDomainSetMaxMemory(dom, kibibytes) != 0) {
vshError(ctl, "%s", _("Unable to change MaxMemorySize"));
ret = false;
}
} else {
- if (virDomainSetMemoryFlags(dom, kibibytes, flags) < 0) {
+ if (virDomainSetMemoryFlags(dom, kibibytes, flags | VIR_DOMAIN_MEM_MAXIMUM) < 0) {
vshError(ctl, "%s", _("Unable to change MaxMemorySize"));
ret = false;
}
--
2.26.2
3 years, 10 months
[PATCH 00/12] Hyper-V serial ports, NICs, and screeshots
by Matt Coleman
This patchset makes the following changes to the Hyper-V driver:
* enable XML parsing and creation of serial ports and NICs
* implement several networking APIs
* implement screenshots
Matt Coleman (12):
hyperv: XML parsing of serial ports
hyperv: add support for creating serial devices
hyperv: XML parsing of Ethernet adapters
hyperv: add support for creating network adapters
hyperv: implement connectListAllNetworks and connectNumOfNetworks
hyperv: implement networkLookupByName and networkLookupByUUID
hyperv: implement connectNumOfDefinedNetworks and
connectListDefinedNetworks
hyperv: implement networkGetAutostart, networkIsActive, and
networkIsPersistent
hyperv: implement networkGetXMLDesc
hyperv: implement domainScreenshot
hyperv: provide a more detailed error message for WSMan faults
news: implement new Hyper-V APIs
NEWS.rst | 12 +
po/POTFILES.in | 1 +
src/hyperv/hyperv_driver.c | 620 ++++++++++++++++++++++++++
src/hyperv/hyperv_network_driver.c | 242 ++++++++++
src/hyperv/hyperv_network_driver.h | 26 ++
src/hyperv/hyperv_wmi.c | 45 +-
src/hyperv/hyperv_wmi.h | 12 +
src/hyperv/hyperv_wmi_classes.h | 36 ++
src/hyperv/hyperv_wmi_generator.input | 309 +++++++++++++
src/hyperv/meson.build | 1 +
10 files changed, 1301 insertions(+), 3 deletions(-)
create mode 100644 src/hyperv/hyperv_network_driver.c
create mode 100644 src/hyperv/hyperv_network_driver.h
--
2.30.0
3 years, 10 months
[PATCH] virNetDevOpenvswitchGetVhostuserIfname: Remove a single '\n' from ifname
by Yalei Li
Ovs-vsctl returns a newline result.
Signed-off-by: Yalei Li <liyl43(a)chinatelecom.cn>
---
src/util/virnetdevopenvswitch.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/util/virnetdevopenvswitch.c b/src/util/virnetdevopenvswitch.c
index f9b3369b2a..bd840bd3b7 100644
--- a/src/util/virnetdevopenvswitch.c
+++ b/src/util/virnetdevopenvswitch.c
@@ -575,6 +575,7 @@ virNetDevOpenvswitchGetVhostuserIfname(const char *path,
return 0;
}
+ virStringTrimOptionalNewline(*ifname);
if (virNetDevOpenvswitchMaybeUnescapeReply(*ifname) < 0) {
VIR_FREE(*ifname);
return -1;
--
2.27.0
3 years, 10 months
[PATCH] Revert "remote: Add libvirtd dependency to virt-guest-shutdown.target"
by Jim Fehlig
Further testing revealed commit f035f53baa regresses Debian bug 955216
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=955216
Restarting libvirt-guests on libvirtd restart is worse than the original
dependency issue, so revert the commit until a better solution is found.
This reverts commit f035f53baa2e5dc00b8e866e594672a90b4cea78.
Signed-off-by: Jim Fehlig <jfehlig(a)suse.com>
---
src/remote/virt-guest-shutdown.target | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/remote/virt-guest-shutdown.target b/src/remote/virt-guest-shutdown.target
index e2efa3e63a..25d4aaa267 100644
--- a/src/remote/virt-guest-shutdown.target
+++ b/src/remote/virt-guest-shutdown.target
@@ -1,4 +1,3 @@
[Unit]
Description=Libvirt guests shutdown
-Requires=libvirtd.service
Documentation=https://libvirt.org
--
2.29.2
3 years, 10 months
[PATCH v2] docs: Clarify the documentation of the <css> elements
by Thomas Huth
The channel subsystem elements describe a channel in the I/O subsystem
of a s390x machine, and not a normal device (like a disk or network card).
Reword the documentation here to make it this a little bit clearer.
Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1898074
Reviewed-by: Boris Fiuczynski <fiuczy(a)linux.ibm.com>
Signed-off-by: Thomas Huth <thuth(a)redhat.com>
---
v2: "channel" -> "subchannel" as suggested by Cornelia
docs/formatnode.html.in | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/docs/formatnode.html.in b/docs/formatnode.html.in
index 1010a37a3d..5c7286df8a 100644
--- a/docs/formatnode.html.in
+++ b/docs/formatnode.html.in
@@ -396,15 +396,15 @@
</dl>
</dd>
<dt><code>css</code></dt>
- <dd>Describes a Channel SubSystem (CSS) device commonly found on
- the S390 architecture. Sub-elements include:
+ <dd>Describes a subchannel in the Channel SubSystem (CSS) commonly
+ found on the S390 architecture. Sub-elements include:
<dl>
<dt><code>cssid</code></dt>
<dd>The channel subsystem identifier.</dd>
<dt><code>ssid</code></dt>
<dd>The subchannel-set identifier.</dd>
<dt><code>devno</code></dt>
- <dd>The device number.</dd>
+ <dd>The subchannel number.</dd>
<dt><code>capability</code></dt>
<dd>
This optional element can occur multiple times. If it
--
2.27.0
3 years, 10 months
[PATCH v5 0/5] migration/dirtyrate: Introduce APIs for getting domain memory dirty rate
by Hao Wang
V4 -> V5:
squash 1/7 and bits of 5/7 and 6/7 into 2/7 in v4 (to be 1/5 in v5)
squash left of 5/7 into 4/7 in v4 (to be 3/5 in v5)
add VIR_DOMAIN_DIRTYRATE_DEFAULT flag
remove redundant error report
rename virsh api to "domdirtyrate"
use vshTablePtr for virsh api output
add description in docs/manpages/virsh.rst
other format optimize
V3 -> V4:
define flags to unsigned int
fix some compile warnings
V2 -> V3:
reorganize patchset to fix compile warning
V1 -> V2:
replace QEMU_JOB_ASYNC with QEMU_JOB_QUERY
Sometimes domain's memory dirty rate is expected by user in order to
decide whether it's proper to be migrated out or not.
We have already completed the QEMU part of the capability:
https://patchew.org/QEMU/1600237327-33618-1-git-send-email-zhengchuan@hua...
And this serial of patches introduce the corresponding LIBVIRT part --
DomainGetDirtyRateInfo API and corresponding virsh api -- "domdirtyrate".
instructions:
bash# virsh domdirtyrate --help
NAME
domdirtyrate - Get a vm's memory dirty rate
SYNOPSIS
domdirtyrate <domain> [--seconds <number>] [--calculate] [--query]
DESCRIPTION
Get memory dirty rate of a domain in order to decide whether it's proper to be migrated out or not.
OPTIONS
[--domain] <string> domain name, id or uuid
--seconds <number> calculate memory dirty rate within specified seconds, the supported value range is [1, 60], default to 1s.
--calculate calculate dirty rate only, can be used together with --query, either or both is expected, otherwise would default to both.
--query query dirty rate only, can be used together with --calculate, either or both is expected, otherwise would default to both.
example:
bash# virsh domdirtyrate vm0 --calculate --query --seconds 1
Item Value
-----------------------------
Status: measured
Start time: 51585
Calculate time: 1 s
Dirty rate: 18 MB/s
Hao Wang (5):
migration/dirtyrate: Introduce DomainGetDirtyRateInfo API
migration/dirtyrate: Implement qemuDomainCalculateDirtyRate
migration/dirtyrate: Implement qemuDomainQueryDirtyRate
migration/dirtyrate: Implement qemuDomainGetDirtyRateInfo
migration/dirtyrate: Introduce domdirtyrate virsh api
docs/manpages/virsh.rst | 17 +++++
include/libvirt/libvirt-domain.h | 59 ++++++++++++++
src/driver-hypervisor.h | 7 ++
src/libvirt-domain.c | 56 ++++++++++++++
src/libvirt_public.syms | 5 ++
src/qemu/qemu_driver.c | 67 ++++++++++++++++
src/qemu/qemu_migration.c | 48 ++++++++++++
src/qemu/qemu_migration.h | 10 +++
src/qemu/qemu_monitor.c | 24 ++++++
src/qemu/qemu_monitor.h | 8 ++
src/qemu/qemu_monitor_json.c | 99 ++++++++++++++++++++++++
src/qemu/qemu_monitor_json.h | 8 ++
src/remote/remote_driver.c | 1 +
src/remote/remote_protocol.x | 21 ++++-
tools/virsh-domain.c | 127 +++++++++++++++++++++++++++++++
15 files changed, 556 insertions(+), 1 deletion(-)
--
2.23.0
3 years, 10 months
[PATCH 00/14] util: Remove VIR_DISPOSE(_N)
by Peter Krempa
Most callers are way better off using memset directly additionally few
places didn't even use it to clear sensitive data in the first place
since the name probably sounded as the right thing to use.
Peter Krempa (14):
hypervFreeInvokeParams: Don't use VIR_DISPOSE_N for freeing 'params'
libxlMakeDomBuildInfo: Don't use VIR_DISPOSE_N for USB device list
storage_backend_iscsi(_direct): Properly clear secrets
libxlMakeNetworkDiskSrc: Avoid use of VIR_DISPOSE_N
qemuDomainMasterKeyCreate: Don't use VIR_DISPOSE_N on failure
qemu: domain: Use memset for clearing secrets instead of VIR_DISPOSE_N
cmdSecretSetValue: Make it obvious that --file, --base64 and
--interactive are exlcusive
virsh: cmdSecretSetValue: Rework handling of the secret value
virsh: cmdSecretGetValue: Use memset instead of VIR_DISPOSE_N
virStorageBackendRBDOpenRADOSConn: Use memset instead of VIR_DISPOSE_N
virCryptoEncryptDataAESgnutls: Use memset instead of VIR_DISPOSE_N
storageBackendCreateQemuImgSecretPath: Use memset instead of
VIR_DISPOSE_N
tests: viralloc: Remove testDispose case
util: viralloc: Remove VIR_DISPOSE(_N)
src/hyperv/hyperv_wmi.c | 4 +-
src/libvirt_private.syms | 1 -
src/libxl/libxl_conf.c | 8 +--
src/qemu/qemu_domain.c | 24 ++++++---
src/storage/storage_backend_iscsi.c | 16 +++---
src/storage/storage_backend_iscsi_direct.c | 17 ++++---
src/storage/storage_backend_rbd.c | 5 +-
src/storage/storage_util.c | 5 +-
src/util/viralloc.c | 39 +-------------
src/util/viralloc.h | 27 ----------
src/util/vircrypto.c | 3 +-
tests/viralloctest.c | 34 -------------
tools/virsh-secret.c | 59 ++++++++++------------
13 files changed, 76 insertions(+), 166 deletions(-)
--
2.29.2
3 years, 10 months
[PATCH] util: virstring: Remove unused prototypes for virStr(n)dup
by Peter Krempa
The headers weren't removed after use of VIR_STRDUP was removed.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/util/virstring.h | 7 -------
1 file changed, 7 deletions(-)
diff --git a/src/util/virstring.h b/src/util/virstring.h
index 55547b040a..cfd24f0b74 100644
--- a/src/util/virstring.h
+++ b/src/util/virstring.h
@@ -123,13 +123,6 @@ int virStrcpy(char *dest, const char *src, size_t destbytes)
G_GNUC_WARN_UNUSED_RESULT;
#define virStrcpyStatic(dest, src) virStrcpy((dest), (src), sizeof(dest))
-/* Don't call these directly - use the macros below */
-int virStrdup(char **dest, const char *src)
- G_GNUC_WARN_UNUSED_RESULT ATTRIBUTE_NONNULL(1);
-
-int virStrndup(char **dest, const char *src, ssize_t n)
- G_GNUC_WARN_UNUSED_RESULT ATTRIBUTE_NONNULL(1);
-
size_t virStringListLength(const char * const *strings);
int virStringSortCompare(const void *a, const void *b);
--
2.29.2
3 years, 10 months
[libvirt PATCH v2 00/10] Random bits found by clang-tidy
by Tim Wiederhake
clang-tidy is a static code analysis tool under the llvm umbrella. It is
primarily meant to be used on C++ code bases, but some of the checks it
provides also apply to C.
The findings vary in severity and contain pseudo-false-positives, i.e.
clang-tidy is flagging potential execution flows that could happen in
theory but are virtually impossible in real life: In function
`virGetUnprivSGIOSysfsPath`, variables `maj` and `min` would be read
unintialized if `stat()` failed and set `errno` to a negative value, to name
just one example.
The main source of false positive findings is the lack of support for
`__attribute__((cleanup))` in clang-tidy, which is heavily used in libvirt
through glib's `g_autofree` and `g_auto()` macros:
#include <stdlib.h>
void freeptr(int** p) {
if (*p)
free(*p);
}
int main() {
__attribute__((cleanup(freeptr))) int *ptr = NULL;
ptr = calloc(sizeof(int), 1);
return 0; /* flagged as memory leak of `ptr` */
}
This sadly renders clang-tidy's analysis of dynamic memory useless, hiding all
real issues that it could otherwise find.
Meson provides excellent integration for clang-tidy (a "clang-tidy" target is
automatically generated if a ".clang-tidy" configuration file is present
in the project's root directory). The amount of false-positives (many of
which present in a group of checks that cannot be disabled), random segfaults
in memory constraint environments such as the containers in the CI, and the
slow analysis (triggering time-outs in the CI), make this tool unfit for
inclusion in libvirt's GitLab CI though.
The patches in this series are the result of fixing some of the issues
reported by running
CC=clang meson build
ninja -C build # generate sources and header files
ninja -C build clang-tidy
with the following `.clang-tidy` configuration file:
---
Checks: >
*,
-abseil-*,
-android-*,
-boost-*,
-cppcoreguidelines-*,
-fuchsia-*,
-google-*,
-hicpp-*,
-llvm-*,
-modernize-*,
-mpi-,
-objc-,
-openmp-,
-zircon-*,
-readability-braces-around-statements,
-readability-magic-numbers
WarningsAsErrors: '*'
HeaderFilterRegex: ''
FormatStyle: none
...
V1: https://www.redhat.com/archives/libvir-list/2021-January/msg01152.html
Changes since V1:
* Expanded the justification for the "Replace bzero() with memset()" patch.
* Rewrote "udevProcessCCW: Initialize variable".
* Rewrote "tests: Prevent mallo with size 0".
* Dropped "vircommand: Remove NULL check in virCommandAddArg".
Note that this series now depends on the rewrite of tests/commandhelper.c,
which can be found here:
https://www.redhat.com/archives/libvir-list/2021-February/msg00034.html
Regards,
Tim
Tim Wiederhake (10):
virfile: Remove redundant #ifndef
xen: Fix indentation in xenParseXLSpice
qemu_tpm: Fix indentation in qemuTPMEmulatorBuildCommand
virsh-domain: Fix error handling of pthread_sigmask
Replace bzero() with memset()
udevProcessCCW: Initialize variable
virhostuptime: Fix rounding in uptime calculation
tests: Prevent malloc with size 0
vircryptotest: Directly assign string to avoid memcpy
vircommand: Simplify virCommandAddArg
src/libxl/xen_xl.c | 5 ++---
src/node_device/node_device_udev.c | 2 +-
src/qemu/qemu_tpm.c | 8 +++++---
src/util/virarptable.c | 2 +-
src/util/vircommand.c | 7 +------
src/util/virfile.c | 4 ++--
src/util/virhostuptime.c | 4 +++-
tests/commandhelper.c | 3 +++
tests/vircryptotest.c | 5 +----
tests/virpcimock.c | 2 +-
tools/virsh-domain.c | 8 ++++----
11 files changed, 24 insertions(+), 26 deletions(-)
--
2.26.2
3 years, 10 months