[RFCv2 00/46] RFC: Generate parsexml/formatbuf functions based on directives
by Shi Lei
V1 here: [https://www.redhat.com/archives/libvir-list/2020-June/msg00357.html]
Differ from V1:
* Move the generator into scripts/xmlgen and rename it 'xmlgen'.
* Declare virXMLChildNode and virXMLChildNodeSet in libvirt_private.syms.
* Replace VIR_FREE with g_free and VIR_ALLOC[_N] with g_new0.
* Adjust virReportError to avoid unnecessary translation.
* Remove the macro VIR_USED and use G_GNUC_UNUSED to declare arguments.
* When parsing string member, assign value to it directly instead of
using middle variable.
* Don't set libclang_path. Just use python-clang's default setting.
* Use virEscapeString for escaping xml characters.
* Enable directive 'genformat' with a parameter to support separation mode.
* Add directive 'xmlswitch' and 'xmlgroup' to support discriminated unions.
* Allow directive 'array' and 'specified' to carry with a parameter,
which specifies its counterpart explicitly.
* Enable directive 'xmlattr' with path.
* Add directive 'formatflag' and 'formathook'.
For those new and changed directives, illustrate them by an example:
struct _virDomainGraphicsAuthDef { /* genparse, genformat:separate */
char *passwd; /* xmlattr, formatflag:VIR_DOMAIN_DEF_FORMAT_SECURE */
bool expires;
time_t validTo; /* xmlattr:passwdValidTo, specified:expires */
virDomainGraphicsAuthConnectedType connected; /* xmlattr */
};
struct _virDomainGraphicsListenDef { /* genparse:withhook, genformat */
virDomainGraphicsListenType type; /* xmlattr */
char *address; /* xmlattr, formathook */
char *network; /* xmlattr, formatflag:VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK */
char *socket; /* xmlattr, formathook */
int fromConfig; /* xmlattr, formatflag:%VIR_DOMAIN_DEF_FORMAT_STATUS */
bool autoGenerated; /* xmlattr, formatflag:%VIR_DOMAIN_DEF_FORMAT_STATUS */
};
struct _virDomainGraphicsSDLDef { /* genparse, genformat:separate */
char *display; /* xmlattr */
char *xauth; /* xmlattr */
bool fullscreen; /* xmlattr */
virTristateBool gl; /* xmlattr:gl/enable */
};
struct _virDomainGraphicsDef { /* genparse:concisehook, genformat */
virObjectPtr privateData;
virDomainGraphicsType type; /* xmlattr */
size_t nListens;
virDomainGraphicsListenDefPtr listens; /* xmlelem, array:nListens */
union {
virDomainGraphicsSDLDef sdl; /* xmlgroup */
virDomainGraphicsVNCDef vnc; /* xmlgroup */
virDomainGraphicsRDPDef rdp; /* xmlgroup */
virDomainGraphicsDesktopDef desktop; /* xmlgroup */
virDomainGraphicsSpiceDef spice; /* xmlgroup */
virDomainGraphicsEGLHeadlessDef egl_headless; /* xmlgroup */
} data; /* xmlswitch:type */
};
Explanation for these directives:
- genformat[:separate|onlyattrs|onlyelems]
Only work on a struct.
Generate formatbuf function for this struct only if 'genformat' is specified.
The function name is based on struct-name and suffixed with 'FormatBuf'.
When 'genformat:separate' is specified, generate two formatbuf functions
rather than a single full-mode formatbuf function.
One for formatting attributes and another for formatting elements.
These function names are based on struct-name and suffixed with 'FormatAttr'
and 'FormatElem' respectively.
The 'onlyattrs' and 'onlyelems' are just like 'separate', but only
generate one of those two functions according to its denotation.
- xmlattr[:[parentname/]thename]
Parse/Format the field as an XML attribute or
attribute wrapped by an XML element.
If only 'thename' is specified, use it as the XML attribute name;
or use the filed name.
The 'parentname' is the name of the attribute's parent element.
If 'parentname/thename' is specified, the corresponding form is
<parentname thename='..' />.
- xmlgroup
The field is a struct, but its corresponding form in XML is a group
rather than an element.
- xmlswitch:thename
Only for discriminated union. 'thename' is the name of its relative enum.
The name of each union member should match a shortname of the enum.
- array[:countername]
Parse/Format the field as an array.
Each array field must have an related counter field, which name is
specified by 'countername'.
If 'countername' is omitted, follow the pattern:
n + 'field_name'.
- specified[:thename]
This field has an related field to indicate its existence, and
'thename' specifies the name of this related field.
When 'thename' is omitted, follow the pattern:
'field_name' + '_specified'.
- formatflag:[!|%]flag
This field will be formatted and written out to XML only if the 'flag'
hits a target flagset.
The target flagset is passed into the formatbuf function through the
argument 'opaque'.
Adding a '!' before 'flag' means NOT hitting.
Adding a '%' before 'flag' means that flag hitting-check is the unique
condition for formatting this field. For example,
for 'passwd' in 'virDomainGraphicsAuthDef', the directive is:
formatflag:VIR_DOMAIN_DEF_FORMAT_SECURE
then the generated code:
if (def->passwd && (virXMLFlag(opaque) & VIR_DOMAIN_DEF_FORMAT_SECURE))
virBufferEscapeString(buf, " passwd='%s'", def->passwd);
If '%' is inserted like this:
formatflag:%VIR_DOMAIN_DEF_FORMAT_SECURE
then the generated code:
if ((virXMLFlag(opaque) & VIR_DOMAIN_DEF_FORMAT_SECURE))
virBufferEscapeString(buf, " passwd='%s'", def->passwd);
- formathook
Introduce hooks to handle the field if xmlgen can't deal with it now.
E.g., virDomainGraphicsListenDef have two fields with 'formathook',
which are 'address' and 'socket'.
The xmlgen will generate the declaration of some hooks for formatting
these fields and developers should implement them.
1) Check the declaration of hook by a commandline.
# ./scripts/xmlgen/go show virDomainGraphicsListenDef -kf
int
virDomainGraphicsListenDefFormatHook(const virDomainGraphicsListenDef *def,
const void *parent,
const void *opaque,
virBufferPtr addressBuf,
virBufferPtr socketBuf);
bool
virDomainGraphicsListenDefCheckHook(const virDomainGraphicsListenDef *def,
const void *parent,
void *opaque,
bool result);
2) Implement these two hooks in src/conf/domain_conf.c.
2.1) virXXXFormatHook
It is the hook for formatting field 'address' and 'socket'.
The 'addressBuf' and 'socketBuf' are used for output destinations respectively.
2.2) virXXXCheckHook
For structs, the xmlgen generates virXXXCheck function to come with
the virXXXFormatBuf. The virXXXCheck reports whether the corresponding
XML element is null.
The virXXXCheckHook intercepts the 'result' of virXXXCheck. It changes 'result'
or just forwards it according to those fields with 'formathook'.
Thanks!
Shi Lei (46):
scripts: Add a tool to generate xml parse/format functions
maint: Check python3-clang
maint: Call xmlgen automatically when c-head-files change
util: Add some xml-helper-functions to cooperate with xmlgen
util: Add helper functions for 'bool' and 'time_t' and cooperate with
xmlgen
util: Add parsexml/formatbuf helper functions for virSocketAddr
conf: Extract error-checking code from virNetworkDNSTxtDefParseXML
conf: Replace virNetworkDNSTxtDefParseXML(hardcoded) with
namesake(generated)
conf: Generate virNetworkDNSTxtDefFormatBuf
conf: Extract error-checking code from virNetworkDNSSrvDefParseXML
conf: Replace virNetworkDNSSrvDefParseXML(hardcoded) with
namesake(generated)
conf: Generate virNetworkDNSSrvDefFormatBuf
conf: Extract error-checking code from virNetworkDNSHostDefParseXML
conf: Replace virNetworkDNSHostDefParseXML(hardcoded) with
namesake(generated)
conf: Generate virNetworkDNSHostDefFormatBuf
conf: Extract virNetworkDNSForwarderParseXML from
virNetworkDNSParseXML
conf: Replace virNetworkDNSForwarderParseXML(hardcoded) with
namesake(generated)
conf: Generate virNetworkDNSForwarderFormatBuf
conf: Extract error-checking code from virNetworkDNSDefParseXML
conf: Replace virNetworkDNSDefParseXML(hardcoded) with
namesake(generated)
conf: Generate virNetworkDNSDefFormatBuf
conf: Extract embedded structs from virDomainGraphicsDef as standalone
structs
conf: Replace virDomainGraphicsDefParseXMLSDL(hardcoded) with
virDomainGraphicsSDLDefParseXML(generated)
conf: Generate format functions for virDomainGraphicsSDLDef
conf: Replace virDomainGraphicsAuthDefParseXML(hardcoded) with
namesake(generated)
conf: Generate format functions for virDomainGraphicsAuthDef
conf: Extract error-checking code from virDomainGraphicsDefParseXMLVNC
conf: Replace virDomainGraphicsDefParseXMLVNC(hardcoded) with
virDomainGraphicsVNCDefParseXML(generated)
conf: Generate virDomainGraphicsVNCDefFormatAttr
conf: Extract error-checking code from virDomainGraphicsDefParseXMLRDP
conf: Replace virDomainGraphicsDefParseXMLRDP(hardcoded) with
virDomainGraphicsRDPDefParseXML(generated)
conf: Generate virDomainGraphicsRDPDefFormatAttr
conf: Replace virDomainGraphicsDefParseXMLDesktop(hardcoded) with
virDomainGraphicsDesktopDefParseXML(generated)
conf: Generate virDomainGraphicsDesktopDefFormatAttr
conf: Add virSpiceChannelDef to help to parse the member 'channels' of
virDomainGraphicsSpiceDef
conf: Extract error-checking code from
virDomainGraphicsDefParseXMLSpice
conf: Replace virDomainGraphicsDefParseXMLSpice(hardcoded) with
virDomainGraphicsSpiceDefParseXML(generated)
conf: Generate virDomainGraphicsSpiceDefFormatElem and
virDomainGraphicsSpiceDefFormatAttr
conf: Replace virDomainGraphicsDefParseXMLEGLHeadless(hardcoded) with
virDomainGraphicsEGLHeadlessDefParseXML(generated)
conf: Generate virDomainGraphicsEGLHeadlessDefFormatElem
conf: Extract error-checking code from
virDomainGraphicsListenDefParseXML
conf: Replace virDomainGraphicsListenDefParseXML(hardcoded) with
namesake(generated)
conf: Generate virDomainGraphicsListenDefFormatBuf
conf: Extract error-checking code from virDomainGraphicsDefParseXML
conf: Replace virDomainGraphicsDefParseXML(hardcoded) with
namesake(generated)
conf: Replace virDomainGraphicsDefFormat(hardcoded) with
virDomainGraphicsDefFormatBuf(generated)
meson.build | 5 +
po/POTFILES.in | 3 +
scripts/meson.build | 8 +
scripts/xmlgen/directive.py | 1115 ++++++++++++++++++++
scripts/xmlgen/go | 7 +
scripts/xmlgen/main.py | 439 ++++++++
scripts/xmlgen/utils.py | 121 +++
src/conf/domain_conf.c | 1650 +++++++++---------------------
src/conf/domain_conf.h | 179 ++--
src/conf/meson.build | 41 +
src/conf/network_conf.c | 467 ++-------
src/conf/network_conf.h | 54 +-
src/conf/virconftypes.h | 18 +
src/libvirt_private.syms | 9 +
src/meson.build | 6 +
src/qemu/qemu_command.c | 4 +
src/qemu/qemu_driver.c | 2 +
src/qemu/qemu_hotplug.c | 2 +
src/qemu/qemu_migration_cookie.c | 1 +
src/qemu/qemu_process.c | 5 +
src/qemu/qemu_validate.c | 2 +
src/util/virsocketaddr.c | 42 +
src/util/virsocketaddr.h | 26 +-
src/util/virstring.c | 57 ++
src/util/virstring.h | 9 +
src/util/virxml.c | 105 ++
src/util/virxml.h | 6 +
src/vmx/vmx.c | 1 +
tests/meson.build | 1 +
tools/meson.build | 2 +
30 files changed, 2738 insertions(+), 1649 deletions(-)
create mode 100644 scripts/xmlgen/directive.py
create mode 100755 scripts/xmlgen/go
create mode 100755 scripts/xmlgen/main.py
create mode 100644 scripts/xmlgen/utils.py
--
2.25.1
3 years, 11 months
[libvirt][RFC PATCH] add a new 'default' option for attribute mode in numatune
by Luyao Zhong
Hi Libvirt experts,
I would like enhence the numatune snippet configuration. Given a example snippet:
<domain>
...
<numatune>
<memory mode="strict" nodeset="1-4,^3"/>
<memnode cellid="0" mode="strict" nodeset="1"/>
<memnode cellid="2" mode="preferred" nodeset="2"/>
</numatune>
...
</domain>
Currently, attribute mode is either 'interleave', 'strict', or 'preferred',
I propose to add a new 'default' option. I give the reason as following.
Presume we are using cgroups v1, Libvirt sets cpuset.mems for all vcpu threads
according to 'nodeset' in memory element. And translate the memnode element to
qemu config options (--object memory-backend-ram) for per numa cell, which
invoking mbind() system call at the end.[1]
But what if we want using default memory policy and request each guest numa cell
pinned to different host memory nodes? We can't use mbind via qemu config options,
because (I quoto here) "For MPOL_DEFAULT, the nodemask and maxnode arguments must
be specify the empty set of nodes." [2]
So my solution is introducing a new 'default' option for attribute mode. e.g.
<domain>
...
<numatune>
<memory mode="default" nodeset="1-2"/>
<memnode cellid="0" mode="default" nodeset="1"/>
<memnode cellid="1" mode="default" nodeset="2"/>
</numatune>
...
</domain>
If the mode is 'default', libvirt should avoid generating qemu command line
'--object memory-backend-ram', and invokes cgroups to set cpuset.mems for per guest numa
combining with numa topology config. Presume the numa topology is :
<cpu>
...
<numa>
<cell id='0' cpus='0-3' memory='512000' unit='KiB' />
<cell id='1' cpus='4-7' memory='512000' unit='KiB' />
</numa>
...
</cpu>
Then libvirt should set cpuset.mems to '1' for vcpus 0-3, and '2' for vcpus 4-7.
Is this reasonable and feasible? Welcome any comments.
Regards,
Luyao
[1]https://github.com/qemu/qemu/blob/f2a1cf9180f63e88bb38ff21c169da97c3f2b...
[2]https://man7.org/linux/man-pages/man2/mbind.2.html
--
2.25.1
3 years, 12 months
[PATCH v2 0/5] Hypervisor CPU Baseline Cleanups and Fixes
by Collin Walling
The following patches provide some TLC to the hypervisor CPU baseline
handler within the qemu_driver code.
#1 checks for the cpu-model-expansion capability before
executing the baseline handler since it is used for feature expansion.
#2 fixes a styling where a < 0 condition was missing from one of the
if (function()) lines for consistency's sake.
#3 will check if the cpu definition(s) are valid and contain a model
name.
#4 checks the cpu definition(s) model names against the model names
known by the hypervisor. This patch must come before #5.
#5 will allow the baseline command to be ran with a single cpu
definition, whereas before the command would simply fail with an
unhelpful error message. A CPU model expansion will be performed in
this case, which will produce the same result as if the model were
actually baselined.
Note: without patch #4, #5 can result in a segfault in the case where
a single CPU model is provided and the model is not recognized by the
hypervisor. This is because cpu model expansion will return 0 and the
result will be NULL.
Since the QMP response returns "GenericError" in the case of a missing
CPU model, or if the command is not supported (and perhaps for other
reasons I am unsure of -- the response does not explicitly detail that
the CPU model provided was erroneous), we cannot rely on this
response always meaning there was a missing CPU model.
So, to be safe-and-sure, the CPU model is checked against the list of
CPU models known to the hypervisor prior to baselining / expanding
(which were retrieved at some point previously during libvirt init).
Collin Walling (5):
qemu: check for model-expansion cap before baselining
qemu: fix one instance of rc check styling in baseline
qemu: report error if missing model name when baselining
qemu: check if cpu model is supported before baselining
qemu: fix error message when baselining with a single cpu
src/qemu/qemu_driver.c | 45 ++++++++++++++++++++++++++++++++++--------
1 file changed, 37 insertions(+), 8 deletions(-)
--
2.26.2
3 years, 12 months
Races / crashes in shutdown of libvirtd daemon
by Daniel P. Berrangé
We got a new BZ filed about a libvirtd crash in shutdown
https://bugzilla.redhat.com/show_bug.cgi?id=1828207
We can see from the stack trace that the "interface" driver is in
the middle of servicing an RPC call for virConnectListAllInterfaces()
Meanwhile the libvirtd daemon is doing virObjectUnref(dmn) on the
virNetDaemonPtr object.
The fact that it is doing this unref, means that it must have already
call virStateCleanup(), given the code sequence:
/* Run event loop. */
virNetDaemonRun(dmn);
ret = 0;
virHookCall(VIR_HOOK_DRIVER_DAEMON, "-", VIR_HOOK_DAEMON_OP_SHUTDOWN,
0, "shutdown", NULL, NULL);
cleanup:
/* Keep cleanup order in inverse order of startup */
virNetDaemonClose(dmn);
virNetlinkEventServiceStopAll();
if (driversInitialized) {
/* NB: Possible issue with timing window between driversInitialized
* setting if virNetlinkEventServerStart fails */
driversInitialized = false;
virStateCleanup();
}
virObjectUnref(adminProgram);
virObjectUnref(srvAdm);
virObjectUnref(qemuProgram);
virObjectUnref(lxcProgram);
virObjectUnref(remoteProgram);
virObjectUnref(srv);
virObjectUnref(dmn);
Unless I'm missing something non-obvious, this cleanup code path is
inherantly broken & racy. When virNetDaemonRun() returns the RPC
worker threads are all still active. They are all liable to still
be executing RPC calls, which means any of the drivers may be in
use. So calling virStateCleanup() is an inherantly dangerous
thing to do. There is the further complication that once we have
exitted the main loop we may prevent the RPC calls from ever
completing, as they may be waiting on an event to be dispatched.
I know we're had various patch proposals in the past to improve the
robustness of shutdown cleanup but I can't remember the outcome of the
reviews. Hopefully people involved in those threads can jump in here...
IMHO the key problem here is the virNetDeamonRun() method which just
looks at the "quit" flag and immediately returns if it is set.
This needs to be changed so that when it sees quit == true, it takes
the following actions
1. Call virNetDaemonClose() to drop all RPC clients and thus prevent
new RPC calls arriving
2. Flush any RPC calls which are queued but not yet assigned to a
worker thread
3. Tell worker threads to exit after finishing their current job
4. Wait for all worker threads to exit
5. Now virNetDaemonRun may return
At this point we can call virStateCleanup and the various other
things, as we know no drivers are still active in RPC calls.
Having said that, there could be background threads in the the
drivers which are doing work that uses the event loop thread.
So we probably need a virStateClose() method that we call from
virNetDaemonRun, *after* all worker threads are gone, which would
cleanup any background threads while the event loop is still
running.
The issue is that step 4 above ("Wait for all worker threads to exit")
may take too long, or indeed never complete. To deal with this, it
will need a timeout. In the remote_daemon.c cleanup code path, if
there are still worker threads present, then we need to skip all
cleanup and simply call _exit(0) to terminate the process with no
attempt at cleanup, since it would be unsafe to try anything else.
Regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
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 Open Source Contribution
by Barrett J Schonefeld
Hey libvirt team,
We (Ryan Gahagan, Dustan Helm, and Barrett Schonefeld) are computer science
students at the University of Texas at Austin. We are taking a course in
virtualization, and we’d like to contribute to the libvirt repository as
part of this course. Here are the issues we are most interested in:
https://gitlab.com/libvirt/libvirt/-/issues/11
https://gitlab.com/libvirt/libvirt/-/issues/16
Additionally, we would like to take a look at issue 4 (
https://gitlab.com/libvirt/libvirt/-/issues/4), the UDP slowdown for QEMU.
We expect issue 4 to be more time-intensive, and we would like to
communicate with you to ensure we’re solving the problem effectively.
Our course only runs until the end of the fall semester, so our time to
contribute to this project is somewhat limited. If you think any of the
issues we picked would be too difficult to accomplish during that time
frame, we would appreciate alternative suggestions. We really hope to
contribute to this project and help make improvements where we can.
Best regards,
Dustan Helm: dustan.helm(a)yahoo.com
Barrett Schonefeld: bschoney(a)utexas.edu
Ryan Gahagan: ryangahagan18(a)gmail.com
4 years
[PATCH 0/2] qemu: migration corner case fix and cleanup
by Nikolay Shirokovskiy
Nikolay Shirokovskiy (2):
qemu: fix qemuMigrationSrcCleanup to use qemuMigrationJobFinish
qemu: don't needlessly unset close callback during perform phase
src/qemu/qemu_migration.c | 14 +++-----------
1 file changed, 3 insertions(+), 11 deletions(-)
--
1.8.3.1
4 years
[libvirt PATCH v2 00/10] remote: introduce a custom netcat impl for ssh tunnelling
by Daniel P. Berrangé
We have long had a problem with use of netcat for ssh tunnelling because
there's no guarantee the UNIX socket path the client builds will match
the UNIX socket path the remote host uses. We don't even allow session
mode SSH tunnelling for this reason. We also can't easily auto-spawn
libvirtd in session mode.
With the introduction of modular daemons we also have potential for two
completely different UNIX socket paths even for system mode, and the
client can't know which to use.
The solution to all these problems is to introduce a custom netcat impl.
Instead passing the UNIX socket path, we pass the libvirt driver URI.
The custom netcat then decides which socket path to use based on the
remote build host environment.
We still have to support netcat for interoperability with legacy libvirt
versions, but we can default to the new virt-nc.
Daniel P. Berrangé (10):
rpc: merge logic for generating remote SSH shell script
remote: push logic for default netcat binary into common helper
remote: split off enums into separate source file
remote: split out function for parsing URI scheme
remote: parse the remote transport string earlier
remote: split out function for constructing socket path
remote: extract logic for determining daemon to connect to
remote: introduce virt-ssh-helper binary
rpc: switch order of args in virNetClientNewSSH
rpc: use new virt-ssh-helper binary for remote tunnelling
build-aux/syntax-check.mk | 2 +-
docs/uri.html.in | 24 +-
libvirt.spec.in | 2 +
po/POTFILES.in | 2 +
src/libvirt_remote.syms | 1 +
src/remote/Makefile.inc.am | 33 +++
src/remote/remote_driver.c | 323 ++++---------------------
src/remote/remote_sockets.c | 277 +++++++++++++++++++++
src/remote/remote_sockets.h | 70 ++++++
src/remote/remote_ssh_helper.c | 425 +++++++++++++++++++++++++++++++++
src/rpc/virnetclient.c | 166 ++++++++-----
src/rpc/virnetclient.h | 29 ++-
src/rpc/virnetsocket.c | 37 +--
src/rpc/virnetsocket.h | 4 +-
tests/virnetsockettest.c | 12 +-
15 files changed, 1035 insertions(+), 372 deletions(-)
create mode 100644 src/remote/remote_sockets.c
create mode 100644 src/remote/remote_sockets.h
create mode 100644 src/remote/remote_ssh_helper.c
--
2.26.2
4 years
[RFC PATCH v2] fix error message in virMigrate3 if connection is broken
by Nikolay Shirokovskiy
Changes from v1 [1]:
- return error value from VIR_DRV_SUPPORTS_FEATURE instead
of setting error to out argument (decrease over enginering
level on patch generator in other words :)
Currently virDomainMigrate3 reports "this function is not supported by the
connection driver: virDomainMigrate3" if connection to destination for example
is broken. This is a bit misleading.
This is a result of we treat errors as unsupported feature in
VIR_DRV_SUPPORTS_FEATURE macro. Let's return error from macro as is.
I guess all the other occurences of VIR_DRV_SUPPORTS_FEATURE need to be updated
as well so that we detect errors early and not have issues similar to
virDomainMigrate3. I'm going to fix the other places if this RFC is approved.
[1] https://www.redhat.com/archives/libvir-list/2020-September/msg01056.html
---
src/driver.h | 14 ++++++++
src/libvirt-domain.c | 91 +++++++++++++++++++++++++++++++++++++---------------
2 files changed, 79 insertions(+), 26 deletions(-)
diff --git a/src/driver.h b/src/driver.h
index 6278aa0..c29b2fa 100644
--- a/src/driver.h
+++ b/src/driver.h
@@ -60,6 +60,20 @@ typedef enum {
(drv)->connectSupportsFeature((conn), (feature)) > 0 : 0)
+/*
+ * A little wrapper for connectSupportsFeature API to test that the API
+ * itself is available first. Return values are same as for API.
+ *
+ * Returns:
+ * -1 on error
+ * 0 feature is not supported
+ * 1 feature is supported
+ */
+#define VIR_DRV_SUPPORTS_FEATURE2(drv, conn, feature) \
+ ((drv)->connectSupportsFeature ? \
+ (drv)->connectSupportsFeature((conn), (feature)) : 0)
+
+
#define __VIR_DRIVER_H_INCLUDES___
#include "driver-hypervisor.h"
diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
index cde86c7..03c357f 100644
--- a/src/libvirt-domain.c
+++ b/src/libvirt-domain.c
@@ -3846,6 +3846,9 @@ virDomainMigrate3(virDomainPtr domain,
const char *dname = NULL;
const char *dxml = NULL;
unsigned long long bandwidth = 0;
+ int rc_src;
+ int rc_dst;
+ int rc;
VIR_DOMAIN_DEBUG(domain, "dconn=%p, params=%p, nparms=%u flags=0x%x",
dconn, params, nparams, flags);
@@ -3878,15 +3881,21 @@ virDomainMigrate3(virDomainPtr domain,
}
if (flags & VIR_MIGRATE_OFFLINE) {
- if (!VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn,
- VIR_DRV_FEATURE_MIGRATION_OFFLINE)) {
+ rc = VIR_DRV_SUPPORTS_FEATURE2(domain->conn->driver, domain->conn,
+ VIR_DRV_FEATURE_MIGRATION_OFFLINE);
+ if (rc < 0) {
+ goto error;
+ } else if (rc == 0) {
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
_("offline migration is not supported by "
"the source host"));
goto error;
}
- if (!VIR_DRV_SUPPORTS_FEATURE(dconn->driver, dconn,
- VIR_DRV_FEATURE_MIGRATION_OFFLINE)) {
+ rc = VIR_DRV_SUPPORTS_FEATURE2(dconn->driver, dconn,
+ VIR_DRV_FEATURE_MIGRATION_OFFLINE);
+ if (rc < 0) {
+ goto error;
+ } else if (rc == 0) {
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
_("offline migration is not supported by "
"the destination host"));
@@ -3899,21 +3908,30 @@ virDomainMigrate3(virDomainPtr domain,
* the flag for just the source side. We mask it out to allow
* migration from newer source to an older destination that
* rejects the flag. */
- if (flags & VIR_MIGRATE_CHANGE_PROTECTION &&
- !VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn,
- VIR_DRV_FEATURE_MIGRATE_CHANGE_PROTECTION)) {
- virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
- _("cannot enforce change protection"));
- goto error;
+ if (flags & VIR_MIGRATE_CHANGE_PROTECTION) {
+ rc = VIR_DRV_SUPPORTS_FEATURE2(domain->conn->driver, domain->conn,
+ VIR_DRV_FEATURE_MIGRATE_CHANGE_PROTECTION);
+ if (rc < 0) {
+ goto error;
+ } else if (rc == 0) {
+ virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
+ _("cannot enforce change protection"));
+ goto error;
+ }
}
flags &= ~VIR_MIGRATE_CHANGE_PROTECTION;
/* Prefer extensible API but fall back to older migration APIs if params
* only contains parameters which were supported by the older API. */
- if (VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn,
- VIR_DRV_FEATURE_MIGRATION_PARAMS) &&
- VIR_DRV_SUPPORTS_FEATURE(dconn->driver, dconn,
- VIR_DRV_FEATURE_MIGRATION_PARAMS)) {
+ rc_src = VIR_DRV_SUPPORTS_FEATURE2(domain->conn->driver, domain->conn,
+ VIR_DRV_FEATURE_MIGRATION_PARAMS);
+ if (rc_src < 0)
+ goto error;
+ rc_dst = VIR_DRV_SUPPORTS_FEATURE2(dconn->driver, dconn,
+ VIR_DRV_FEATURE_MIGRATION_PARAMS);
+ if (rc_dst < 0)
+ goto error;
+ if (rc_src && rc_dst) {
VIR_DEBUG("Using migration protocol 3 with extensible parameters");
ddomain = virDomainMigrateVersion3Params(domain, dconn, params,
nparams, flags);
@@ -3939,17 +3957,30 @@ virDomainMigrate3(virDomainPtr domain,
goto error;
}
- if (VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn,
- VIR_DRV_FEATURE_MIGRATION_V3) &&
- VIR_DRV_SUPPORTS_FEATURE(dconn->driver, dconn,
- VIR_DRV_FEATURE_MIGRATION_V3)) {
+ rc_src = VIR_DRV_SUPPORTS_FEATURE2(domain->conn->driver, domain->conn,
+ VIR_DRV_FEATURE_MIGRATION_V3);
+ if (rc_src < 0)
+ goto error;
+ rc_dst = VIR_DRV_SUPPORTS_FEATURE2(dconn->driver, dconn,
+ VIR_DRV_FEATURE_MIGRATION_V3);
+ if (rc_dst < 0)
+ goto error;
+ if (rc_src && rc_dst) {
VIR_DEBUG("Using migration protocol 3");
ddomain = virDomainMigrateVersion3(domain, dconn, dxml, flags,
dname, uri, bandwidth);
- } else if (VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn,
- VIR_DRV_FEATURE_MIGRATION_V2) &&
- VIR_DRV_SUPPORTS_FEATURE(dconn->driver, dconn,
- VIR_DRV_FEATURE_MIGRATION_V2)) {
+ goto done;
+ }
+
+ rc_src = VIR_DRV_SUPPORTS_FEATURE2(domain->conn->driver, domain->conn,
+ VIR_DRV_FEATURE_MIGRATION_V2);
+ if (rc_src < 0)
+ goto error;
+ rc_dst = VIR_DRV_SUPPORTS_FEATURE2(dconn->driver, dconn,
+ VIR_DRV_FEATURE_MIGRATION_V2);
+ if (rc_dst < 0)
+ goto error;
+ if (rc_src && rc_dst) {
VIR_DEBUG("Using migration protocol 2");
if (dxml) {
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
@@ -3959,10 +3990,18 @@ virDomainMigrate3(virDomainPtr domain,
}
ddomain = virDomainMigrateVersion2(domain, dconn, flags,
dname, uri, bandwidth);
- } else if (VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn,
- VIR_DRV_FEATURE_MIGRATION_V1) &&
- VIR_DRV_SUPPORTS_FEATURE(dconn->driver, dconn,
- VIR_DRV_FEATURE_MIGRATION_V1)) {
+ goto done;
+ }
+
+ rc_src = VIR_DRV_SUPPORTS_FEATURE2(domain->conn->driver, domain->conn,
+ VIR_DRV_FEATURE_MIGRATION_V1);
+ if (rc_src < 0)
+ goto error;
+ rc_dst = VIR_DRV_SUPPORTS_FEATURE2(dconn->driver, dconn,
+ VIR_DRV_FEATURE_MIGRATION_V1);
+ if (rc_dst < 0)
+ goto error;
+ if (rc_src && rc_dst) {
VIR_DEBUG("Using migration protocol 1");
if (dxml) {
virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s",
--
1.8.3.1
4 years, 1 month