[libvirt] [PATCH] qemu: remove unused cfg variables
by Ján Tomko
These functions got a reference to the driver config
without actually using it:
processNicRxFilterChangedEvent
qemuConnectDomainXMLToNative
Signed-off-by: Ján Tomko <jtomko(a)redhat.com>
---
Pushed as trivial.
src/qemu/qemu_driver.c | 6 ------
1 file changed, 6 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index cee3257a8a..cafd5c0fc7 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -4607,7 +4607,6 @@ processNicRxFilterChangedEvent(virQEMUDriverPtr driver,
virDomainObjPtr vm,
const char *devAlias)
{
- virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
qemuDomainObjPrivatePtr priv = vm->privateData;
virDomainDeviceDef dev;
virDomainNetDefPtr def;
@@ -4706,7 +4705,6 @@ processNicRxFilterChangedEvent(virQEMUDriverPtr driver,
cleanup:
virNetDevRxFilterFree(hostFilter);
virNetDevRxFilterFree(guestFilter);
- virObjectUnref(cfg);
}
@@ -7483,13 +7481,10 @@ static char *qemuConnectDomainXMLToNative(virConnectPtr conn,
virCommandPtr cmd = NULL;
char *ret = NULL;
size_t i;
- virQEMUDriverConfigPtr cfg;
virCapsPtr caps = NULL;
virCheckFlags(0, NULL);
- cfg = virQEMUDriverGetConfig(driver);
-
if (virConnectDomainXMLToNativeEnsureACL(conn) < 0)
goto cleanup;
@@ -7549,7 +7544,6 @@ static char *qemuConnectDomainXMLToNative(virConnectPtr conn,
virCommandFree(cmd);
virObjectUnref(vm);
virObjectUnref(caps);
- virObjectUnref(cfg);
return ret;
}
--
2.19.2
5 years, 1 month
[libvirt] [PATCH v4 00/26] scripts: convert most perl scripts to python
by Daniel P. Berrangé
This series is an effort to reduce the number of different
languages we use by eliminating most use of perl in favour
of python.
This aligns with fact that the likely future build system
we'll use (meson) is written in python, and that python
is much more commonly used/understood by developers these
days than perl.
With this applied we use perl in a handful of places only:
- src/rpc/gendispatch.pl - this is a horrendously large
script and very hard to understand/follow. A straight
syntax conversion to Python would still leave a hgue
and hard to understand/follow script. It really needs
a clean room rewrite from scratch, with better structure.
- src/rpc/genprotocol.pl - fairly easy to convert, but
might be obsolete depending on approach for rewriting
gendispatch.pl, so ignored for now
- tests/oomtrace.pl - will be purge by the patches that
drop OOM handling anyway
- tools/wireshark/util/genxdrstub.pl - a very large
script, which I haven't got the courage to tackle
yet.
- cfg.mk/maint.mk - many syntax rules involve regexes
which are fed to perl. Decision on what to do
with syntax-check rules punted to another time.
- build-aux/gitlog-to-changelog
- build-aux/useless-if-before-free - Both pulled in
from gnulib. Could be rewritten quite easily if
desired, but given that we aren't maintainers of
them right now, they're ignored as they don't
really impact our developers.
Note that the check-spacing.py script is significantly
slower in Python than in Perl. After researching this
it appears there is nothing that can be done. The Perl
regex engine is simply much better optimized than the
Python one. As previously discussed we need to loook
at uncrustify or clang-format or some other tool to
validate whitespace formatting. This is ongoing. We
can either accept the slow down in the short term or
keep the Perl version in the short term.
In v4:
- Moved all scripts into the scripts/ directory instead
of having them scattered around source tree
- Use re.search instead of re.match
- Don't bother re-compiling regexes
In v3:
- All scripts comply with all flake8 style rules with
exception of
E129 visually indented line with same indent as next logical line
In v2:
- Pulled in patch to hacking file
- Converted many more scripts
- Forced UTF-8 character set to avoid ascii codec
on py3 < 3.7
Daniel P. Berrangé (26):
build: fix use of $(AUG_GENTEST) as a dependency
build-aux: rewrite augeas test generator in Python
build-aux: rewrite po file minimizer in Python
build-aux: rewrite duplicate header checker in Python
build-aux: rewrite whitespace checker in Python
build-aux: rewrite mock inline checker in Python
build-aux: rewrite header ifdef checker in Python
src: rewrite ACL permissions checker in Python
src: rewrite symfile sorting checker in Python
src: rewrite symfile library checker in Python
src: rewrite systemtap probe generator in Python
src: rewrite systemtap function generator in Python
src: rewrite driver name checker in Python
src: rewrite driver impl checker in Python
src: rewrite ACL rule checker in Python
src: rewrite polkit ACL generator in Python
src: rewrite remote protocol checker in Python
tests: rewrite test argv line wrapper in Python
tests: rewrite qemu capability grouper in Python
tests: rewrite file access checker in Python
docs: rewrite hvsupport.html page generator in python
docs: rewrite polkit docs generator in Python
docs: move apibuild.py to the scripts/ directory
docs: move reformat-news.py to the scripts/ directory
docs: move esx_vi_generator.py to the scripts/ directory
docs: move hyperv_wmi_generator.py to the scripts/ directory
.gitignore | 3 +-
Makefile.am | 37 +-
build-aux/augeas-gentest.pl | 60 ---
build-aux/check-spacing.pl | 198 -------
build-aux/header-ifdef.pl | 182 -------
build-aux/minimize-po.pl | 37 --
build-aux/mock-noinline.pl | 75 ---
build-aux/prohibit-duplicate-header.pl | 26 -
cfg.mk | 32 +-
docs/Makefile.am | 16 +-
docs/genaclperms.pl | 125 -----
docs/hvsupport.pl | 458 ----------------
po/Makefile.am | 2 +-
{docs => scripts}/apibuild.py | 0
scripts/augeas-gentest.py | 67 +++
scripts/check-aclperms.py | 75 +++
scripts/check-aclrules.py | 263 +++++++++
scripts/check-driverimpls.py | 102 ++++
scripts/check-drivername.py | 114 ++++
scripts/check-file-access.py | 123 +++++
scripts/check-remote-protocol.py | 136 +++++
scripts/check-spacing.py | 229 ++++++++
scripts/check-symfile.py | 80 +++
scripts/check-symsorting.py | 117 ++++
scripts/dtrace2systemtap.py | 143 +++++
{src/esx => scripts}/esx_vi_generator.py | 0
scripts/genaclperms.py | 123 +++++
scripts/genpolkit.py | 122 +++++
scripts/gensystemtap.py | 184 +++++++
scripts/group-qemu-caps.py | 123 +++++
scripts/header-ifdef.py | 231 ++++++++
scripts/hvsupport.py | 503 ++++++++++++++++++
.../hyperv_wmi_generator.py | 0
scripts/minimize-po.py | 58 ++
scripts/mock-noinline.py | 85 +++
scripts/prohibit-duplicate-header.py | 56 ++
{docs => scripts}/reformat-news.py | 0
scripts/test-wrap-argv.py | 170 ++++++
src/Makefile.am | 155 ++----
src/access/Makefile.inc.am | 6 +-
src/access/genpolkit.pl | 119 -----
src/bhyve/Makefile.inc.am | 4 +-
src/check-aclperms.pl | 73 ---
src/check-aclrules.pl | 252 ---------
src/check-driverimpls.pl | 80 ---
src/check-drivername.pl | 83 ---
src/check-symfile.pl | 70 ---
src/check-symsorting.pl | 106 ----
src/dtrace2systemtap.pl | 130 -----
src/esx/Makefile.inc.am | 5 +-
src/hyperv/Makefile.inc.am | 5 +-
src/interface/Makefile.inc.am | 2 +-
src/libxl/Makefile.inc.am | 4 +-
src/locking/Makefile.inc.am | 6 +-
src/logging/Makefile.inc.am | 2 +-
src/lxc/Makefile.inc.am | 4 +-
src/network/Makefile.inc.am | 2 +-
src/node_device/Makefile.inc.am | 2 +-
src/nwfilter/Makefile.inc.am | 2 +-
src/qemu/Makefile.inc.am | 4 +-
src/remote/Makefile.inc.am | 4 +-
src/rpc/Makefile.inc.am | 1 -
src/rpc/gensystemtap.pl | 193 -------
src/secret/Makefile.inc.am | 2 +-
src/storage/Makefile.inc.am | 2 +-
src/vbox/Makefile.inc.am | 2 +-
src/vz/Makefile.inc.am | 2 +-
tests/Makefile.am | 3 +-
tests/check-file-access.pl | 126 -----
tests/file_access_whitelist.txt | 2 +-
tests/group-qemu-caps.pl | 124 -----
tests/test-wrap-argv.pl | 174 ------
tests/testutils.c | 16 +-
73 files changed, 3243 insertions(+), 2879 deletions(-)
delete mode 100755 build-aux/augeas-gentest.pl
delete mode 100755 build-aux/check-spacing.pl
delete mode 100644 build-aux/header-ifdef.pl
delete mode 100755 build-aux/minimize-po.pl
delete mode 100644 build-aux/mock-noinline.pl
delete mode 100644 build-aux/prohibit-duplicate-header.pl
delete mode 100755 docs/genaclperms.pl
delete mode 100755 docs/hvsupport.pl
rename {docs => scripts}/apibuild.py (100%)
create mode 100755 scripts/augeas-gentest.py
create mode 100755 scripts/check-aclperms.py
create mode 100755 scripts/check-aclrules.py
create mode 100755 scripts/check-driverimpls.py
create mode 100644 scripts/check-drivername.py
create mode 100755 scripts/check-file-access.py
create mode 100644 scripts/check-remote-protocol.py
create mode 100755 scripts/check-spacing.py
create mode 100755 scripts/check-symfile.py
create mode 100755 scripts/check-symsorting.py
create mode 100755 scripts/dtrace2systemtap.py
rename {src/esx => scripts}/esx_vi_generator.py (100%)
create mode 100755 scripts/genaclperms.py
create mode 100755 scripts/genpolkit.py
create mode 100755 scripts/gensystemtap.py
create mode 100755 scripts/group-qemu-caps.py
create mode 100644 scripts/header-ifdef.py
create mode 100755 scripts/hvsupport.py
rename {src/hyperv => scripts}/hyperv_wmi_generator.py (100%)
create mode 100755 scripts/minimize-po.py
create mode 100644 scripts/mock-noinline.py
create mode 100644 scripts/prohibit-duplicate-header.py
rename {docs => scripts}/reformat-news.py (100%)
create mode 100755 scripts/test-wrap-argv.py
delete mode 100755 src/access/genpolkit.pl
delete mode 100755 src/check-aclperms.pl
delete mode 100755 src/check-aclrules.pl
delete mode 100755 src/check-driverimpls.pl
delete mode 100755 src/check-drivername.pl
delete mode 100755 src/check-symfile.pl
delete mode 100755 src/check-symsorting.pl
delete mode 100755 src/dtrace2systemtap.pl
delete mode 100755 src/rpc/gensystemtap.pl
delete mode 100755 tests/check-file-access.pl
delete mode 100755 tests/group-qemu-caps.pl
delete mode 100755 tests/test-wrap-argv.pl
--
2.21.0
5 years, 1 month
[libvirt] [PATCH 0/3] use virStringParseYesNo helper
by Mao Zhongyi
A function virStringParseYesNo was added to convert
string 'yes' to true and 'no' to false, so use this
helper to replace 'STREQ(.*, \"yes\")' and
'STREQ(.*, \"no\")' as it allows us to drop several
repetitive if-then-else string->bool conversion blocks.
Cc: abologna(a)redhat.com
Cc: berrange(a)redhat.com
Cc: crobinso(a)redhat.com
Cc: gene(a)czarc.net
Cc: g.sho1500(a)gmail.com
Cc: jdenemar(a)redhat.com
Cc: laine(a)laine.org
Cc: mkletzan(a)redhat.com
Cc: phrdina(a)redhat.com
Mao Zhongyi (3):
conf/domain_conf: use virStringParseYesNo helper
conf/network_conf: use virStringParseYesNo helper
qemu/qemu_migration_params: use virStringParseYesNo helper
src/conf/domain_conf.c | 30 ++++++++++++++----------------
src/conf/network_conf.c | 4 +---
src/qemu/qemu_migration_params.c | 6 +-----
3 files changed, 16 insertions(+), 24 deletions(-)
--
2.17.1
5 years, 1 month
[libvirt] [PATCH v2 00/31] qemu: Store default CPU in domain XML
by Jiri Denemark
When starting a domain without a CPU model specified in the domain XML,
QEMU will choose a default one. Which is fine unless the domain gets
migrated to another host because libvirt doesn't perform any CPU ABI
checks and the virtual CPU provided by QEMU on the destination host can
differ from the one on the source host.
With QEMU 4.2.0 we can probe for the default CPU model used by QEMU for
a particular machine type and store it in the domain XML. This way the
chosen CPU model is more visible to users and libvirt will make sure
the guest will see the exact same CPU after migration.
https://bugzilla.redhat.com/show_bug.cgi?id=1598151
https://bugzilla.redhat.com/show_bug.cgi?id=1598162
---
Some patches were too large so I decided to shorten them before sending
to the list. You can check the full version of this series with
git fetch https://gitlab.com/jirkade/libvirt cpu-default-type
Jiri Denemark (31):
tests: Add capabilities for QEMU 4.2.0 on s390x
domcapstest: Add test case for QEMU 4.2.0 on s390x
conf: Use VIR_AUTO* in virDomainCapsCPUModelsAdd
conf: Drop nameLen parameter from virDomainCapsCPUModelsAdd
qemu: Copy CPU models in virQEMUCapsGetCPUDefinitions
qemu: Filter models in virQEMUCapsGetCPUDefinitions
qemu: Use virQEMUCapsGetCPUDefinitions more
qemu: Use VIR_AUTOPTR in qemuMonitorJSONGetCPUDefinitions
qemu: Change return type of virQEMUCapsFetchCPUDefinitions
qemu: Introduce qemuMonitorCPUDefs struct
qemu: Flatten qemuMonitorCPUDefs.cpus
build: Export virStringListCopy internal API
qemu: Add qemuMonitorCPUDefsCopy
qemu: Use VIR_AUTOFREE in virQEMUCapsLoadCPUModels
qemu: Introduce virQEMUCapsCPUDefsToModels
qemu: Rename virQEMUCaps{Get,Fetch}CPUDefinitions
qemu: Split virQEMUCapsFetchCPUModels
qemu: Switch qemuCaps to use qemuMonitorCPUDefs
conf: Drop unused virDomainCapsCPUModelsFilter
conf: Drop virDomainCapsCPUModelsAddSteal
qemu: Store typename from query-cpu-definitions in qemuCaps
qemu: Probe for default CPU types
qemu: Introduce virQEMUCapsGetMachineDefaultCPU
qemu: Drop unused virQEMUCapsGetDefaultMachine
qemu: Use VIR_AUTOUNREF in qemuDomainDefPostParse
conf: Define VIR_AUTOPTR for virCPUDef
qemuxml2*test: Add test cases for default CPU models on aarch64
qemuxml2*test: Add test cases for default CPU models on ppc64
qemuxml2*test: Add test cases for default CPU models on s390x
qemuxml2*test: Add test cases for default CPU models on x86_64
qemu: Store default CPU in domain XML
src/conf/cpu_conf.h | 1 +
src/conf/domain_capabilities.c | 86 +-
src/conf/domain_capabilities.h | 8 -
src/libvirt_private.syms | 3 +-
src/qemu/qemu_capabilities.c | 358 +-
src/qemu/qemu_capabilities.h | 15 +-
src/qemu/qemu_domain.c | 84 +-
src/qemu/qemu_driver.c | 4 +-
src/qemu/qemu_monitor.c | 74 +-
src/qemu/qemu_monitor.h | 18 +-
src/qemu/qemu_monitor_json.c | 82 +-
src/qemu/qemu_monitor_json.h | 2 +-
src/qemu/qemu_process.c | 24 +-
tests/cputest.c | 7 +-
.../domaincapsschemadata/qemu_4.2.0.s390x.xml | 202 +
tests/domaincapstest.c | 4 +
.../caps_2.10.0.aarch64.xml | 126 +-
.../caps_2.10.0.ppc64.xml | 512 +-
.../caps_2.10.0.s390x.xml | 264 +-
.../caps_2.10.0.x86_64.xml | 132 +-
.../caps_2.11.0.s390x.xml | 264 +-
.../caps_2.11.0.x86_64.xml | 136 +-
.../caps_2.12.0.aarch64.xml | 136 +-
.../caps_2.12.0.ppc64.xml | 516 +-
.../caps_2.12.0.s390x.xml | 264 +-
.../caps_2.12.0.x86_64.xml | 180 +-
.../qemucapabilitiesdata/caps_2.9.0.ppc64.xml | 512 +-
.../qemucapabilitiesdata/caps_2.9.0.s390x.xml | 256 +-
.../caps_2.9.0.x86_64.xml | 128 +-
.../qemucapabilitiesdata/caps_3.0.0.ppc64.xml | 516 +-
.../qemucapabilitiesdata/caps_3.0.0.s390x.xml | 272 +-
.../caps_3.0.0.x86_64.xml | 184 +-
.../qemucapabilitiesdata/caps_3.1.0.ppc64.xml | 516 +-
.../caps_3.1.0.x86_64.xml | 196 +-
.../caps_4.0.0.aarch64.xml | 148 +-
.../qemucapabilitiesdata/caps_4.0.0.ppc64.xml | 516 +-
.../qemucapabilitiesdata/caps_4.0.0.s390x.xml | 284 +-
.../caps_4.0.0.x86_64.xml | 196 +-
.../caps_4.1.0.x86_64.xml | 400 +-
.../caps_4.2.0.aarch64.xml | 242 +-
.../qemucapabilitiesdata/caps_4.2.0.ppc64.xml | 574 +-
.../caps_4.2.0.s390x.replies | 22414 ++++++++++++++++
.../qemucapabilitiesdata/caps_4.2.0.s390x.xml | 3345 +++
.../caps_4.2.0.x86_64.xml | 492 +-
tests/qemumonitorjsontest.c | 38 +-
...fault-cpu-kvm-virt-4.2.aarch64-latest.args | 38 +
.../aarch64-default-cpu-kvm-virt-4.2.xml | 20 +
...fault-cpu-tcg-virt-4.2.aarch64-latest.args | 39 +
.../aarch64-default-cpu-tcg-virt-4.2.xml | 20 +
.../disk-cache.x86_64-latest.args | 1 +
.../disk-cdrom-network.x86_64-latest.args | 1 +
.../disk-cdrom-tray.x86_64-latest.args | 1 +
.../disk-copy_on_read.x86_64-latest.args | 1 +
.../disk-detect-zeroes.x86_64-latest.args | 1 +
.../disk-floppy-q35-2_11.x86_64-latest.args | 1 +
.../disk-floppy-q35-2_9.x86_64-latest.args | 1 +
.../os-firmware-bios.x86_64-latest.args | 1 +
...os-firmware-efi-secboot.x86_64-latest.args | 1 +
.../os-firmware-efi.x86_64-latest.args | 1 +
...ault-cpu-kvm-pseries-2.7.ppc64-latest.args | 38 +
.../ppc64-default-cpu-kvm-pseries-2.7.xml | 22 +
...ault-cpu-kvm-pseries-3.1.ppc64-latest.args | 38 +
.../ppc64-default-cpu-kvm-pseries-3.1.xml | 22 +
...ault-cpu-kvm-pseries-4.2.ppc64-latest.args | 38 +
.../ppc64-default-cpu-kvm-pseries-4.2.xml | 22 +
...ault-cpu-tcg-pseries-2.7.ppc64-latest.args | 39 +
.../ppc64-default-cpu-tcg-pseries-2.7.xml | 22 +
...ault-cpu-tcg-pseries-3.1.ppc64-latest.args | 39 +
.../ppc64-default-cpu-tcg-pseries-3.1.xml | 22 +
...ault-cpu-tcg-pseries-4.2.ppc64-latest.args | 39 +
.../ppc64-default-cpu-tcg-pseries-4.2.xml | 22 +
...t-cpu-kvm-ccw-virtio-4.2.s390x-latest.args | 31 +
.../s390-default-cpu-kvm-ccw-virtio-4.2.xml | 16 +
...t-cpu-tcg-ccw-virtio-4.2.s390x-latest.args | 32 +
.../s390-default-cpu-tcg-ccw-virtio-4.2.xml | 16 +
.../tpm-emulator-tpm2-enc.x86_64-latest.args | 1 +
.../tpm-emulator-tpm2.x86_64-latest.args | 1 +
.../tpm-emulator.x86_64-latest.args | 1 +
.../tseg-explicit-size.x86_64-latest.args | 1 +
.../vhost-vsock-auto.x86_64-latest.args | 1 +
.../vhost-vsock.x86_64-latest.args | 1 +
...-default-cpu-kvm-pc-4.2.x86_64-latest.args | 37 +
.../x86_64-default-cpu-kvm-pc-4.2.xml | 24 +
...default-cpu-kvm-q35-4.2.x86_64-latest.args | 42 +
.../x86_64-default-cpu-kvm-q35-4.2.xml | 24 +
...-default-cpu-tcg-pc-4.2.x86_64-latest.args | 37 +
.../x86_64-default-cpu-tcg-pc-4.2.xml | 24 +
...default-cpu-tcg-q35-4.2.x86_64-latest.args | 42 +
.../x86_64-default-cpu-tcg-q35-4.2.xml | 24 +
tests/qemuxml2argvtest.c | 15 +
...efault-cpu-kvm-virt-4.2.aarch64-latest.xml | 38 +
...efault-cpu-tcg-virt-4.2.aarch64-latest.xml | 41 +
.../os-firmware-bios.x86_64-latest.xml | 3 +
.../os-firmware-efi-secboot.x86_64-latest.xml | 3 +
.../os-firmware-efi.x86_64-latest.xml | 3 +
...fault-cpu-kvm-pseries-2.7.ppc64-latest.xml | 45 +
...fault-cpu-kvm-pseries-3.1.ppc64-latest.xml | 45 +
...fault-cpu-kvm-pseries-4.2.ppc64-latest.xml | 45 +
...fault-cpu-tcg-pseries-2.7.ppc64-latest.xml | 48 +
...fault-cpu-tcg-pseries-3.1.ppc64-latest.xml | 48 +
...fault-cpu-tcg-pseries-4.2.ppc64-latest.xml | 48 +
...lt-cpu-kvm-ccw-virtio-4.2.s390x-latest.xml | 23 +
...lt-cpu-tcg-ccw-virtio-4.2.s390x-latest.xml | 26 +
.../tpm-emulator-tpm2-enc.x86_64-latest.xml | 3 +
.../tpm-emulator-tpm2.x86_64-latest.xml | 3 +
.../tpm-emulator.x86_64-latest.xml | 3 +
.../tpm-passthrough-crb.x86_64-latest.xml | 3 +
.../tpm-passthrough.x86_64-latest.xml | 3 +
...4-default-cpu-kvm-pc-4.2.x86_64-latest.xml | 40 +
...-default-cpu-kvm-q35-4.2.x86_64-latest.xml | 63 +
...4-default-cpu-tcg-pc-4.2.x86_64-latest.xml | 40 +
...-default-cpu-tcg-q35-4.2.x86_64-latest.xml | 63 +
tests/qemuxml2xmltest.c | 15 +
113 files changed, 31926 insertions(+), 4317 deletions(-)
create mode 100644 tests/domaincapsschemadata/qemu_4.2.0.s390x.xml
create mode 100644 tests/qemucapabilitiesdata/caps_4.2.0.s390x.replies
create mode 100644 tests/qemucapabilitiesdata/caps_4.2.0.s390x.xml
create mode 100644 tests/qemuxml2argvdata/aarch64-default-cpu-kvm-virt-4.2.aarch64-latest.args
create mode 100644 tests/qemuxml2argvdata/aarch64-default-cpu-kvm-virt-4.2.xml
create mode 100644 tests/qemuxml2argvdata/aarch64-default-cpu-tcg-virt-4.2.aarch64-latest.args
create mode 100644 tests/qemuxml2argvdata/aarch64-default-cpu-tcg-virt-4.2.xml
create mode 100644 tests/qemuxml2argvdata/ppc64-default-cpu-kvm-pseries-2.7.ppc64-latest.args
create mode 100644 tests/qemuxml2argvdata/ppc64-default-cpu-kvm-pseries-2.7.xml
create mode 100644 tests/qemuxml2argvdata/ppc64-default-cpu-kvm-pseries-3.1.ppc64-latest.args
create mode 100644 tests/qemuxml2argvdata/ppc64-default-cpu-kvm-pseries-3.1.xml
create mode 100644 tests/qemuxml2argvdata/ppc64-default-cpu-kvm-pseries-4.2.ppc64-latest.args
create mode 100644 tests/qemuxml2argvdata/ppc64-default-cpu-kvm-pseries-4.2.xml
create mode 100644 tests/qemuxml2argvdata/ppc64-default-cpu-tcg-pseries-2.7.ppc64-latest.args
create mode 100644 tests/qemuxml2argvdata/ppc64-default-cpu-tcg-pseries-2.7.xml
create mode 100644 tests/qemuxml2argvdata/ppc64-default-cpu-tcg-pseries-3.1.ppc64-latest.args
create mode 100644 tests/qemuxml2argvdata/ppc64-default-cpu-tcg-pseries-3.1.xml
create mode 100644 tests/qemuxml2argvdata/ppc64-default-cpu-tcg-pseries-4.2.ppc64-latest.args
create mode 100644 tests/qemuxml2argvdata/ppc64-default-cpu-tcg-pseries-4.2.xml
create mode 100644 tests/qemuxml2argvdata/s390-default-cpu-kvm-ccw-virtio-4.2.s390x-latest.args
create mode 100644 tests/qemuxml2argvdata/s390-default-cpu-kvm-ccw-virtio-4.2.xml
create mode 100644 tests/qemuxml2argvdata/s390-default-cpu-tcg-ccw-virtio-4.2.s390x-latest.args
create mode 100644 tests/qemuxml2argvdata/s390-default-cpu-tcg-ccw-virtio-4.2.xml
create mode 100644 tests/qemuxml2argvdata/x86_64-default-cpu-kvm-pc-4.2.x86_64-latest.args
create mode 100644 tests/qemuxml2argvdata/x86_64-default-cpu-kvm-pc-4.2.xml
create mode 100644 tests/qemuxml2argvdata/x86_64-default-cpu-kvm-q35-4.2.x86_64-latest.args
create mode 100644 tests/qemuxml2argvdata/x86_64-default-cpu-kvm-q35-4.2.xml
create mode 100644 tests/qemuxml2argvdata/x86_64-default-cpu-tcg-pc-4.2.x86_64-latest.args
create mode 100644 tests/qemuxml2argvdata/x86_64-default-cpu-tcg-pc-4.2.xml
create mode 100644 tests/qemuxml2argvdata/x86_64-default-cpu-tcg-q35-4.2.x86_64-latest.args
create mode 100644 tests/qemuxml2argvdata/x86_64-default-cpu-tcg-q35-4.2.xml
create mode 100644 tests/qemuxml2xmloutdata/aarch64-default-cpu-kvm-virt-4.2.aarch64-latest.xml
create mode 100644 tests/qemuxml2xmloutdata/aarch64-default-cpu-tcg-virt-4.2.aarch64-latest.xml
create mode 100644 tests/qemuxml2xmloutdata/ppc64-default-cpu-kvm-pseries-2.7.ppc64-latest.xml
create mode 100644 tests/qemuxml2xmloutdata/ppc64-default-cpu-kvm-pseries-3.1.ppc64-latest.xml
create mode 100644 tests/qemuxml2xmloutdata/ppc64-default-cpu-kvm-pseries-4.2.ppc64-latest.xml
create mode 100644 tests/qemuxml2xmloutdata/ppc64-default-cpu-tcg-pseries-2.7.ppc64-latest.xml
create mode 100644 tests/qemuxml2xmloutdata/ppc64-default-cpu-tcg-pseries-3.1.ppc64-latest.xml
create mode 100644 tests/qemuxml2xmloutdata/ppc64-default-cpu-tcg-pseries-4.2.ppc64-latest.xml
create mode 100644 tests/qemuxml2xmloutdata/s390-default-cpu-kvm-ccw-virtio-4.2.s390x-latest.xml
create mode 100644 tests/qemuxml2xmloutdata/s390-default-cpu-tcg-ccw-virtio-4.2.s390x-latest.xml
create mode 100644 tests/qemuxml2xmloutdata/x86_64-default-cpu-kvm-pc-4.2.x86_64-latest.xml
create mode 100644 tests/qemuxml2xmloutdata/x86_64-default-cpu-kvm-q35-4.2.x86_64-latest.xml
create mode 100644 tests/qemuxml2xmloutdata/x86_64-default-cpu-tcg-pc-4.2.x86_64-latest.xml
create mode 100644 tests/qemuxml2xmloutdata/x86_64-default-cpu-tcg-q35-4.2.x86_64-latest.xml
--
2.23.0
5 years, 1 month
[libvirt] [PATCH] build: Update .gitignore for build-aux files
by John Ferlan
Recent changes moved some files to build-aux and created at least
one more.
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
---
.gitignore | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/.gitignore b/.gitignore
index 85ead5c907..30610a37c9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -43,20 +43,22 @@
/autom4te.cache
/build-aux/.gitignore
/build-aux/compile
+/build-aux/config.guess
+/build-aux/config.sub
/build-aux/depcomp
+/build-aux/install-sh
+/build-aux/ltmain.sh
/build-aux/missing
/build-aux/test-driver
/build/
/ci/scratch/
/confdefs.h
/config.cache
-/config.guess
/config.h
/config.h.in
/config.log
/config.rpath
/config.status
-/config.sub
/configure
/configure.lineno
/conftest.*
@@ -96,7 +98,6 @@
/libvirt*.pc
/libvirt.spec
/ltconfig
-/ltmain.sh
/m4/*
/mingw-libvirt.spec
/mkinstalldirs
--
2.20.1
5 years, 1 month
[libvirt] [PATCH v3 00/10] use VIR_AUTO*/g_auto* all around qemu_driver.c
by Daniel Henrique Barboza
changes from v2:
- rebased with newer master (67e72053c1)
- added an extra patch to convert the existing VIR_AUTO* macros
to g_auto* ones, all at once, to avoid the case where a method
will have both VIR_AUTO* and g_auto* macros at the same time.
Note: the conversion in patch 10 wasn't 100% due to a handful of
methods that I was unable to use g_autoptr. Take for example
the method qemuDomainSaveInternal:
--
qemuDomainObjPrivatePtr priv = vm->privateData;
VIR_AUTOUNREF(virCapsPtr) caps = NULL;
virQEMUSaveDataPtr data = NULL;
VIR_AUTOUNREF(qemuDomainSaveCookiePtr) cookie = NULL;
--
Changing the 'cookie' variable to use g_autoptr() causes an error:
make[3]: Entering directory '/home/danielhb/kvm-project/libvirt/src'
CC qemu/libvirt_driver_qemu_impl_la-qemu_driver.lo
In file included from /usr/lib64/glib-2.0/include/glibconfig.h:9,
from /usr/include/glib-2.0/glib/gtypes.h:32,
from /usr/include/glib-2.0/glib/galloca.h:32,
from /usr/include/glib-2.0/glib.h:30,
from ./internal.h:31,
from qemu/qemu_agent.h:24,
from qemu/qemu_driver.c:40:
qemu/qemu_driver.c: In function 'qemuDomainSaveInternal':
qemu/qemu_driver.c:3282:15: error: unknown type name 'qemuDomainSaveCookie_autoptr'
3282 | g_autoptr(qemuDomainSaveCookie) cookie = NULL;
I tried doing it with the 'Ptr' in the name, same error:
CC qemu/libvirt_driver_qemu_impl_la-qemu_driver.lo
In file included from /usr/lib64/glib-2.0/include/glibconfig.h:9,
from /usr/include/glib-2.0/glib/gtypes.h:32,
from /usr/include/glib-2.0/glib/galloca.h:32,
from /usr/include/glib-2.0/glib.h:30,
from ./internal.h:31,
from qemu/qemu_agent.h:24,
from qemu/qemu_driver.c:40:
qemu/qemu_driver.c: In function 'qemuDomainSaveInternal':
qemu/qemu_driver.c:3282:15: error: unknown type name 'qemuDomainSaveCookiePtr_autoptr'
3282 | g_autoptr(qemuDomainSaveCookiePtr) cookie = NULL;
Similar situation happens with qemuDomainSaveImageStartVM and with
qemuSecurityInit methods. They are mentioned in the commit message
of patch 10 for reference. These methods are still using VIR_AUTO*
macros.
changes from v1:
- addressed review concerns made by Erik
- added more cleanups, as suggested by Erik
v2: https://www.redhat.com/archives/libvir-list/2019-September/msg01452.html
v1: https://www.redhat.com/archives/libvir-list/2019-September/msg00719.html
Daniel Henrique Barboza (10):
qemu_driver: use VIR_AUTOUNREF() with virQEMUDriverConfigPtr 1/3
qemu_driver: use VIR_AUTOUNREF() with virQEMUDriverConfigPtr 2/3
qemu_driver: use VIR_AUTOUNREF() with virQEMUDriverConfigPtr 3/3
qemu_driver: use VIR_AUTOUNREF() with virCapsPtr
qemu_driver: use VIR_AUTOUNREF() with more pointer types
qemu_driver: use VIR_AUTOFREE() with strings 1/3
qemu_driver: use VIR_AUTOFREE() with strings 2/3
qemu_driver: use VIR_AUTOFREE() with strings 3/3
qemu_driver: VIR_AUTOFREE on other scalar pointers
qemu_driver.c: use GLib macros
src/qemu/qemu_driver.c | 755 ++++++++++++++---------------------------
1 file changed, 259 insertions(+), 496 deletions(-)
--
2.21.0
5 years, 1 month
[libvirt] [PATCH 0/9] GLib macros and where to find them (glib chronicles)
by Ján Tomko
Ján Tomko (9):
util: delete VIR_AUTOFREE
Remove all usage of VIR_RETURN_PTR
internal: delete VIR_RETURN_PTR
conf: use g_steal_pointer instead of VIR_STEAL_PTR
qemu: use g_steal_pointer instead of VIR_STEAL_PTR
tools: use g_steal_pointer instead of VIR_STEAL_PTR
util: use g_steal_pointer instead of VIR_STEAL_PTR
Use g_steal_pointer instead of VIR_STEAL_PTR everywhere
internal: delete VIR_STEAL_PTR
src/admin/admin_remote.c | 2 +-
src/admin/admin_server_dispatch.c | 2 +-
src/bhyve/bhyve_domain.c | 2 +-
src/conf/checkpoint_conf.c | 2 +-
src/conf/cpu_conf.c | 18 +--
src/conf/domain_addr.c | 4 +-
src/conf/domain_capabilities.c | 4 +-
src/conf/domain_conf.c | 146 ++++++++++-----------
src/conf/node_device_conf.c | 12 +-
src/conf/secret_conf.c | 2 +-
src/conf/snapshot_conf.c | 8 +-
src/conf/storage_conf.c | 10 +-
src/conf/virnetworkobj.c | 2 +-
src/conf/virnetworkportdef.c | 2 +-
src/conf/virnwfilterbindingobj.c | 2 +-
src/conf/virsecretobj.c | 2 +-
src/conf/virstorageobj.c | 4 +-
src/cpu/cpu_x86.c | 4 +-
src/internal.h | 27 ----
src/libvirt-domain.c | 8 +-
src/libxl/xen_common.c | 2 +-
src/libxl/xen_xl.c | 2 +-
src/libxl/xen_xm.c | 2 +-
src/locking/lock_driver_lockd.c | 6 +-
src/network/bridge_driver.c | 2 +-
src/phyp/phyp_driver.c | 2 +-
src/qemu/qemu_agent.c | 6 +-
src/qemu/qemu_block.c | 50 +++----
src/qemu/qemu_blockjob.c | 18 +--
src/qemu/qemu_capabilities.c | 14 +-
src/qemu/qemu_cgroup.c | 2 +-
src/qemu/qemu_command.c | 12 +-
src/qemu/qemu_conf.c | 6 +-
src/qemu/qemu_dbus.c | 2 +-
src/qemu/qemu_domain.c | 28 ++--
src/qemu/qemu_driver.c | 52 ++++----
src/qemu/qemu_firmware.c | 16 +--
src/qemu/qemu_hotplug.c | 4 +-
src/qemu/qemu_interface.c | 2 +-
src/qemu/qemu_migration.c | 14 +-
src/qemu/qemu_migration_cookie.c | 2 +-
src/qemu/qemu_migration_params.c | 4 +-
src/qemu/qemu_monitor.c | 16 +--
src/qemu/qemu_monitor_json.c | 18 +--
src/qemu/qemu_process.c | 10 +-
src/qemu/qemu_qapi.c | 2 +-
src/qemu/qemu_slirp.c | 4 +-
src/qemu/qemu_vhost_user.c | 8 +-
src/remote/remote_driver.c | 8 +-
src/rpc/virnetlibsshsession.c | 2 +-
src/secret/secret_driver.c | 4 +-
src/security/security_manager.c | 4 +-
src/security/virt-aa-helper.c | 4 +-
src/storage/storage_backend_fs.c | 2 +-
src/storage/storage_backend_gluster.c | 4 +-
src/storage/storage_backend_iscsi_direct.c | 4 +-
src/storage/storage_backend_logical.c | 4 +-
src/storage/storage_backend_rbd.c | 6 +-
src/storage/storage_backend_scsi.c | 2 +-
src/storage/storage_driver.c | 4 +-
src/storage/storage_file_gluster.c | 2 +-
src/storage/storage_util.c | 8 +-
src/test/test_driver.c | 20 +--
src/util/viralloc.h | 14 --
src/util/vircgroupv1.c | 4 +-
src/util/vircgroupv2.c | 2 +-
src/util/virdbus.c | 12 +-
src/util/virdevmapper.c | 2 +-
src/util/virerror.c | 2 +-
src/util/virfile.c | 2 +-
src/util/virfilecache.c | 2 +-
src/util/virhostdev.c | 6 +-
src/util/viriscsi.c | 4 +-
src/util/virjson.c | 4 +-
src/util/virmdev.c | 6 +-
src/util/virnetdevtap.c | 2 +-
src/util/virnetlink.c | 6 +-
src/util/virnuma.c | 4 +-
src/util/virpci.c | 6 +-
src/util/virresctrl.c | 10 +-
src/util/virrotatingfile.c | 2 +-
src/util/virscsi.c | 2 +-
src/util/virscsivhost.c | 2 +-
src/util/virstorageencryption.c | 2 +-
src/util/virstoragefile.c | 36 ++---
src/util/virtypedparam.c | 2 +-
src/vbox/vbox_common.c | 6 +-
src/vmx/vmx.c | 2 +-
src/vz/vz_driver.c | 8 +-
src/vz/vz_sdk.c | 4 +-
tests/networkxml2conftest.c | 2 +-
tests/qemuagenttest.c | 4 +-
tests/qemublocktest.c | 2 +-
tests/qemusecuritytest.c | 2 +-
tests/testutilsqemu.c | 2 +-
tests/virstoragetest.c | 2 +-
tools/virsh-completer-domain.c | 12 +-
tools/virsh-completer-host.c | 4 +-
tools/virsh-completer-interface.c | 2 +-
tools/virsh-completer-network.c | 4 +-
tools/virsh-completer-nodedev.c | 4 +-
tools/virsh-completer-nwfilter.c | 4 +-
tools/virsh-completer-pool.c | 4 +-
tools/virsh-completer-secret.c | 4 +-
tools/virsh-completer-snapshot.c | 2 +-
tools/virsh-completer-volume.c | 2 +-
tools/virsh-completer.c | 2 +-
tools/virsh-domain.c | 2 +-
tools/virsh-snapshot.c | 2 +-
tools/vsh.c | 2 +-
110 files changed, 412 insertions(+), 453 deletions(-)
--
2.19.2
5 years, 1 month
[libvirt] [PATCH 00/10] Clean up error preservation/restoration
by John Ferlan
I was going through some old git trees and found this one started before
I 'altered' my Red Hat career path. Seeing as no one has picked it up from
https://wiki.libvirt.org/page/BiteSizedTasks - figured I may as well post
it rather than throw it away ;-)
The change essentially alters virSaveLastError ... virSetError and
virFreeError paths to use virErrorPreserveLast & virErrorRestore.
John Ferlan (10):
conf: Use consistent error preservation and restoration calls
src: Use consistent error preservation and restoration calls
libxl: Use consistent error preservation and restoration calls
lxc: Use consistent error preservation and restoration calls
qemu: Use consistent error preservation and restoration calls
remote: Use consistent error preservation and restoration calls
storage: Use consistent error preservation and restoration calls
util: Use consistent error preservation and restoration calls
vz: Use consistent error preservation and restoration calls
tools: Use consistent error preservation and restoration calls
src/conf/domain_conf.c | 7 +--
src/libvirt-stream.c | 36 +++++-------
src/libxl/libxl_migration.c | 18 ++----
src/lxc/lxc_driver.c | 9 ++-
src/lxc/lxc_process.c | 7 +--
src/qemu/qemu_cgroup.c | 14 ++---
src/qemu/qemu_command.c | 12 ++--
src/qemu/qemu_domain.c | 7 +--
src/qemu/qemu_driver.c | 36 +++++-------
src/qemu/qemu_migration.c | 85 +++++++++------------------
src/qemu/qemu_migration_params.c | 9 ++-
src/qemu/qemu_monitor.c | 19 +++---
src/qemu/qemu_process.c | 7 +--
src/remote/remote_daemon_stream.c | 17 +++---
src/storage/storage_backend_disk.c | 5 +-
src/storage/storage_backend_logical.c | 5 +-
src/storage/storage_driver.c | 8 +--
src/util/vircgroup.c | 18 +++---
src/util/virfirewall.c | 6 +-
src/vz/vz_driver.c | 9 +--
tools/virsh.c | 7 +--
tools/virt-admin.c | 7 +--
22 files changed, 137 insertions(+), 211 deletions(-)
--
2.20.1
5 years, 1 month
[libvirt] [libvirt-rust PATCH 1/1] Make creating safe wrapper from raw pointer unsafe
by Linus Färnstrand
Giving an invalid pointer to the safe wrapper types causes
undefined behavior when methods are later called on said wrapper
Properly document safety contract of using unsafe constructor
---
src/connect.rs | 10 ++++++++--
src/domain.rs | 10 ++++++++--
src/domain_snapshot.rs | 10 ++++++++--
src/interface.rs | 10 ++++++++--
src/network.rs | 10 ++++++++--
src/nodedev.rs | 10 ++++++++--
src/nwfilter.rs | 10 ++++++++--
src/secret.rs | 10 ++++++++--
src/storage_pool.rs | 10 ++++++++--
src/storage_vol.rs | 10 ++++++++--
src/stream.rs | 8 +++++++-
11 files changed, 87 insertions(+), 21 deletions(-)
diff --git a/src/connect.rs b/src/connect.rs
index 108224d..7f02619 100644
--- a/src/connect.rs
+++ b/src/connect.rs
@@ -462,8 +462,14 @@ impl Connect {
self.ptr.unwrap()
}
- pub fn new(ptr: sys::virConnectPtr) -> Connect {
- return Connect { ptr: Some(ptr) };
+ /// Creates a new [Connect] from the given raw pointer.
+ ///
+ /// # Safety
+ ///
+ /// The pointer must point to a valid libvirt connection object.
+ /// The underlying object must be valid for the entire lifetime of the returned instance.
+ pub unsafe fn from_ptr(ptr: sys::virConnectPtr) -> Connect {
+ Connect { ptr: Some(ptr) }
}
pub fn get_version() -> Result<u32, Error> {
diff --git a/src/domain.rs b/src/domain.rs
index acb9e6e..0df95ee 100644
--- a/src/domain.rs
+++ b/src/domain.rs
@@ -628,8 +628,14 @@ impl Drop for Domain {
}
impl Domain {
- pub fn new(ptr: sys::virDomainPtr) -> Domain {
- return Domain { ptr: Some(ptr) };
+ /// Creates a new [Domain] from the given raw pointer.
+ ///
+ /// # Safety
+ ///
+ /// The pointer must point to a valid libvirt domain object.
+ /// The underlying object must be valid for the entire lifetime of the returned instance.
+ pub unsafe fn from_ptr(ptr: sys::virDomainPtr) -> Domain {
+ Domain { ptr: Some(ptr) }
}
pub fn as_ptr(&self) -> sys::virDomainPtr {
diff --git a/src/domain_snapshot.rs b/src/domain_snapshot.rs
index 86599ef..8b6c873 100644
--- a/src/domain_snapshot.rs
+++ b/src/domain_snapshot.rs
@@ -94,8 +94,14 @@ impl Drop for DomainSnapshot {
}
impl DomainSnapshot {
- pub fn new(ptr: sys::virDomainSnapshotPtr) -> DomainSnapshot {
- return DomainSnapshot { ptr: Some(ptr) };
+ /// Creates a new [DomainSnapshot] from the given raw pointer.
+ ///
+ /// # Safety
+ ///
+ /// The pointer must point to a valid libvirt domain snapshot object.
+ /// The underlying object must be valid for the entire lifetime of the returned instance.
+ pub unsafe fn from_ptr(ptr: sys::virDomainSnapshotPtr) -> DomainSnapshot {
+ DomainSnapshot { ptr: Some(ptr) }
}
pub fn as_ptr(&self) -> sys::virDomainSnapshotPtr {
diff --git a/src/interface.rs b/src/interface.rs
index 6fe8742..b06b641 100644
--- a/src/interface.rs
+++ b/src/interface.rs
@@ -81,8 +81,14 @@ impl Drop for Interface {
}
impl Interface {
- pub fn new(ptr: sys::virInterfacePtr) -> Interface {
- return Interface { ptr: Some(ptr) };
+ /// Creates a new [Interface] from the given raw pointer.
+ ///
+ /// # Safety
+ ///
+ /// The pointer must point to a valid libvirt interface object.
+ /// The underlying object must be valid for the entire lifetime of the returned instance.
+ pub unsafe fn from_ptr(ptr: sys::virInterfacePtr) -> Interface {
+ Interface { ptr: Some(ptr) }
}
pub fn as_ptr(&self) -> sys::virInterfacePtr {
diff --git a/src/network.rs b/src/network.rs
index ac8c042..bbe5539 100644
--- a/src/network.rs
+++ b/src/network.rs
@@ -117,8 +117,14 @@ impl Drop for Network {
}
impl Network {
- pub fn new(ptr: sys::virNetworkPtr) -> Network {
- return Network { ptr: Some(ptr) };
+ /// Creates a new [Network] from the given raw pointer.
+ ///
+ /// # Safety
+ ///
+ /// The pointer must point to a valid libvirt network object.
+ /// The underlying object must be valid for the entire lifetime of the returned instance.
+ pub unsafe fn from_ptr(ptr: sys::virNetworkPtr) -> Network {
+ Network { ptr: Some(ptr) }
}
pub fn as_ptr(&self) -> sys::virNetworkPtr {
diff --git a/src/nodedev.rs b/src/nodedev.rs
index c38c49e..2f36ea6 100644
--- a/src/nodedev.rs
+++ b/src/nodedev.rs
@@ -99,8 +99,14 @@ impl Drop for NodeDevice {
}
impl NodeDevice {
- pub fn new(ptr: sys::virNodeDevicePtr) -> NodeDevice {
- return NodeDevice { ptr: Some(ptr) };
+ /// Creates a new [NodeDevice] from the given raw pointer.
+ ///
+ /// # Safety
+ ///
+ /// The pointer must point to a valid libvirt node device object.
+ /// The underlying object must be valid for the entire lifetime of the returned instance.
+ pub unsafe fn from_ptr(ptr: sys::virNodeDevicePtr) -> NodeDevice {
+ NodeDevice { ptr: Some(ptr) }
}
pub fn as_ptr(&self) -> sys::virNodeDevicePtr {
diff --git a/src/nwfilter.rs b/src/nwfilter.rs
index bd9455d..84f440e 100644
--- a/src/nwfilter.rs
+++ b/src/nwfilter.rs
@@ -68,8 +68,14 @@ impl Drop for NWFilter {
}
impl NWFilter {
- pub fn new(ptr: sys::virNWFilterPtr) -> NWFilter {
- return NWFilter { ptr: Some(ptr) };
+ /// Creates a new [NWFilter] from the given raw pointer.
+ ///
+ /// # Safety
+ ///
+ /// The pointer must point to a valid libvirt NWFilter object.
+ /// The underlying object must be valid for the entire lifetime of the returned instance.
+ pub unsafe fn from_ptr(ptr: sys::virNWFilterPtr) -> NWFilter {
+ NWFilter { ptr: Some(ptr) }
}
pub fn as_ptr(&self) -> sys::virNWFilterPtr {
diff --git a/src/secret.rs b/src/secret.rs
index ba96b02..59a3f19 100644
--- a/src/secret.rs
+++ b/src/secret.rs
@@ -100,8 +100,14 @@ impl Drop for Secret {
}
impl Secret {
- pub fn new(ptr: sys::virSecretPtr) -> Secret {
- return Secret { ptr: Some(ptr) };
+ /// Creates a new [Secret] from the given raw pointer.
+ ///
+ /// # Safety
+ ///
+ /// The pointer must point to a valid libvirt secret object.
+ /// The underlying object must be valid for the entire lifetime of the returned instance.
+ pub unsafe fn from_ptr(ptr: sys::virSecretPtr) -> Secret {
+ Secret { ptr: Some(ptr) }
}
pub fn as_ptr(&self) -> sys::virSecretPtr {
diff --git a/src/storage_pool.rs b/src/storage_pool.rs
index 38676c2..b8d9feb 100644
--- a/src/storage_pool.rs
+++ b/src/storage_pool.rs
@@ -156,8 +156,14 @@ impl Drop for StoragePool {
}
impl StoragePool {
- pub fn new(ptr: sys::virStoragePoolPtr) -> StoragePool {
- return StoragePool { ptr: Some(ptr) };
+ /// Creates a new [StoragePool] from the given raw pointer.
+ ///
+ /// # Safety
+ ///
+ /// The pointer must point to a valid libvirt storage pool object.
+ /// The underlying object must be valid for the entire lifetime of the returned instance.
+ pub unsafe fn from_ptr(ptr: sys::virStoragePoolPtr) -> StoragePool {
+ StoragePool { ptr: Some(ptr) }
}
pub fn as_ptr(&self) -> sys::virStoragePoolPtr {
diff --git a/src/storage_vol.rs b/src/storage_vol.rs
index afc9b17..762c615 100644
--- a/src/storage_vol.rs
+++ b/src/storage_vol.rs
@@ -181,8 +181,14 @@ impl Drop for StorageVol {
}
impl StorageVol {
- pub fn new(ptr: sys::virStorageVolPtr) -> StorageVol {
- return StorageVol { ptr: Some(ptr) };
+ /// Creates a new [StorageVol] from the given raw pointer.
+ ///
+ /// # Safety
+ ///
+ /// The pointer must point to a valid libvirt storage volume object.
+ /// The underlying object must be valid for the entire lifetime of the returned instance.
+ pub unsafe fn from_ptr(ptr: sys::virStorageVolPtr) -> StorageVol {
+ StorageVol { ptr: Some(ptr) }
}
pub fn as_ptr(&self) -> sys::virStorageVolPtr {
diff --git a/src/stream.rs b/src/stream.rs
index 8333ee5..ff85bea 100644
--- a/src/stream.rs
+++ b/src/stream.rs
@@ -68,7 +68,13 @@ impl Drop for Stream {
}
impl Stream {
- pub fn new(ptr: sys::virStreamPtr) -> Stream {
+ /// Creates a new [Stream] from the given raw pointer.
+ ///
+ /// # Safety
+ ///
+ /// The pointer must point to a valid libvirt stream object.
+ /// The underlying object must be valid for the entire lifetime of the returned instance.
+ pub unsafe fn from_ptr(ptr: sys::virStreamPtr) -> Stream {
Stream { ptr: Some(ptr) }
}
--
2.21.0
5 years, 1 month