[libvirt] [PATCH] qemu: don't refuse to undefine a guest with NVRAM file
by Daniel P. Berrange
The undefine operation should always be allowed to succeed
regardless of whether any NVRAM file exists. ie we should
not force the application to use the VIR_DOMAIN_UNDEFINE_NVRAM
flag. It is valid for the app to decide it wants the NVRAM
file left on disk, in the same way that disk images are left
on disk at undefine.
---
src/qemu/qemu_driver.c | 20 +++++++-------------
1 file changed, 7 insertions(+), 13 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index bec05d4..302bf48 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -6985,19 +6985,13 @@ qemuDomainUndefineFlags(virDomainPtr dom,
if (!virDomainObjIsActive(vm) &&
vm->def->os.loader && vm->def->os.loader->nvram &&
- virFileExists(vm->def->os.loader->nvram)) {
- if (!(flags & VIR_DOMAIN_UNDEFINE_NVRAM)) {
- virReportError(VIR_ERR_OPERATION_INVALID, "%s",
- _("cannot delete inactive domain with nvram"));
- goto cleanup;
- }
-
- if (unlink(vm->def->os.loader->nvram) < 0) {
- virReportSystemError(errno,
- _("failed to remove nvram: %s"),
- vm->def->os.loader->nvram);
- goto cleanup;
- }
+ virFileExists(vm->def->os.loader->nvram) &&
+ (flags & VIR_DOMAIN_UNDEFINE_NVRAM) &&
+ (unlink(vm->def->os.loader->nvram) < 0)) {
+ virReportSystemError(errno,
+ _("failed to remove nvram: %s"),
+ vm->def->os.loader->nvram);
+ goto cleanup;
}
if (virDomainDeleteConfig(cfg->configDir, cfg->autostartDir, vm) < 0)
--
2.1.0
8 years, 7 months
Re: [libvirt] [PATCH] Oracle VirtualBox 5 support or libvirt
by Eric Blake
[the moderation queue rejected your message for being too large]
On 12/31/1969 05:00 PM, wrote:
> ---
> src/Makefile.am | 1 +
> src/vbox/vbox_CAPI_v5_0.h | 25550 ++++++++++++++++++++++++++++++++++++++++
That's an awfully large patch, particularly if it is mostly generated.
Can you resend, with the patch as a compressed attachment, so that it
can make it through the moderation queue? Is it something that can
logically be broken to smaller pieces, or is it really an all-or-none
addition of the new huge file?
> src/vbox/vbox_V5_0.c | 13 +
> src/vbox/vbox_common.h | 2 +
> src/vbox/vbox_storage.c | 2 +
> src/vbox/vbox_tmpl.c | 290 +-
> src/vbox/vbox_uniformed_api.h | 1 +
> 7 files changed, 25752 insertions(+), 107 deletions(-)
> create mode 100644 src/vbox/vbox_CAPI_v5_0.h
> create mode 100644 src/vbox/vbox_V5_0.c
>
> diff --git a/src/Makefile.am b/src/Makefile.am
> index 314f6df..4a7b85f 100644
> --- a/src/Makefile.am
> +++ b/src/Makefile.am
> @@ -783,6 +783,7 @@ VBOX_DRIVER_SOURCES = \
> vbox/vbox_V4_2_20.c vbox/vbox_CAPI_v4_2_20.h \
> vbox/vbox_V4_3.c vbox/vbox_CAPI_v4_3.h \
> vbox/vbox_V4_3_4.c vbox/vbox_CAPI_v4_3_4.h \
> + vbox/vbox_V5_0.c vbox/vbox_CAPI_v5_0.h \
> vbox/vbox_common.c vbox/vbox_common.h \
> vbox/vbox_uniformed_api.h \
> vbox/vbox_get_driver.h \
> diff --git a/src/vbox/vbox_CAPI_v5_0.h b/src/vbox/vbox_CAPI_v5_0.h
> new file mode 100644
> index 0000000..b296733
> --- /dev/null
> +++ b/src/vbox/vbox_CAPI_v5_0.h
> @@ -0,0 +1,25550 @@
> +/*
> + * Libvirt notice: this file is derived from the VirtualBox SDK, with
> + * libvirt edits (fixing preprocessor indentation by cppi); do not
> + * regenerate in the context of libvirt.
> + */
> +/*
> + * DO NOT EDIT! This is a generated file.
> + *
> + * Header file which provides C declarations for VirtualBox Main API
> + * (COM interfaces), generated from XIDL (XML interface definition).
> + * On Windows (which uses COM instead of XPCOM) the native C support
> + * is used, and most of this file is not used.
> + *
> + * Source : src/VBox/Main/idl/VirtualBox.xidl
> + * Generator : src/VBox/Main/cbinding/capiidl.xsl
> + *
> + * This file contains portions from the following Mozilla XPCOM files:
> + * xpcom/include/xpcom/nsID.h
> + * xpcom/include/nsIException.h
> + * xpcom/include/nsprpub/prtypes.h
> + * xpcom/include/xpcom/nsISupportsBase.h
> + *
> + * These files were originally triple-licensed (MPL/GPL2/LGPL2.1). Oracle
> + * elects to distribute this derived work under the LGPL2.1 only.
> + */
> +
> +/*
> + * Copyright (C) 2008-2015 Oracle Corporation
> + *
> + * This file is part of a free software library; you can redistribute
> + * it and/or modify it under the terms of the GNU Lesser General
> + * Public License version 2.1 as published by the Free Software
> + * Foundation and shipped in the "COPYING.LESSER" file with this library.
> + * The library is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY of any kind.
> + *
> + * Oracle LGPL Disclaimer: For the avoidance of doubt, except that if
> + * any license choice other than GPL or LGPL is available it will
> + * apply instead, Oracle elects to use only the Lesser General Public
> + * License version 2.1 (LGPLv2) at this time for any software where
> + * a choice of LGPL license versions is made available with the
> + * language indicating that LGPLv2 or any later version may be used,
> + * or where a choice of which version of the LGPL is applied is
> + * otherwise unspecified.
> + */
Bummer that the license is restrictive against GPLv3, but no worse than
any of the other files in the same directory, so not your problem.
> height, bitsPerPixel,
> xOrigin, yOrigin);
> -#endif /* VBOX_API_VERSION >= 4003000 */
> +#else /*VBOX_API_VERSION >= 5000000 */
> + PRUint32 gms;
> +
> + return display->vtbl->GetScreenResolution(display, screenId, width,
> + height, bitsPerPixel,
> + xOrigin, yOrigin, &gms);
> +#endif /* VBOX_API_VERSION >= 5000000 */
> +
> }
>
> static nsresult
> @@ -4357,10 +4433,10 @@ _displayTakeScreenShotPNGToArray(IDisplay *display ATTRIBUTE_UNUSED,
> PRUint32 *screenDataSize ATTRIBUTE_UNUSED,
> PRUint8** screenData ATTRIBUTE_UNUSED)
> {
> -#if VBOX_API_VERSION < 4000000
> +#if VBOX_API_VERSION < 4000000 || VBOX_API_VERSION >= 5000000
> vboxUnsupported();
> return 0;
> -#else /* VBOX_API_VERSION >= 4000000 */
> +#else /* VBOX_API_VERSION >= 4000000 && VBOX_API_VERSION < 5000000 */
> return display->vtbl->TakeScreenShotPNGToArray(display, screenId, width,
> height, screenDataSize,
> screenData);
> diff --git a/src/vbox/vbox_uniformed_api.h b/src/vbox/vbox_uniformed_api.h
> index a469968..74e9ac0 100644
> --- a/src/vbox/vbox_uniformed_api.h
> +++ b/src/vbox/vbox_uniformed_api.h
> @@ -628,5 +628,6 @@ void vbox42InstallUniformedAPI(vboxUniformedAPI *pVBoxAPI);
> void vbox42_20InstallUniformedAPI(vboxUniformedAPI *pVBoxAPI);
> void vbox43InstallUniformedAPI(vboxUniformedAPI *pVBoxAPI);
> void vbox43_4InstallUniformedAPI(vboxUniformedAPI *pVBoxAPI);
> +void vbox50InstallUniformedAPI(vboxUniformedAPI *pVBoxAPI);
>
> #endif /* VBOX_UNIFORMED_API_H */
>
8 years, 7 months
[libvirt] [PATCH v2 00/32] Introduce sparse streams
by Michal Privoznik
v2 of:
https://www.redhat.com/archives/libvir-list/2016-April/msg01869.html
diff to v1:
- Reworked public API side of the feature. Event approach is no
longer used. Instead I've implemented synchronous APIs as Dan
suggested.
You can find the code at my github repo too:
https://github.com/zippy2/libvirt/tree/sparse_streams2
BTW: here is a measurement I made:
homer libvirt.git # time ./tools/virsh -c qemu+tcp://lisa/system vol-download /mnt/cdrom/dummy.img /tmp/dummy.img
real 3m9.178s
user 0m32.978s
sys 1m7.758s
homer libvirt.git # time ./tools/virsh -c qemu+tcp://lisa/system vol-download --sparse /mnt/cdrom/dummy.img /tmp/dummy.img
real 0m1.409s
user 0m0.017s
sys 0m1.042s
masina libvirt.git # ls -lhs /tmp/dummy.img
4.0K -rw-r--r-- 1 root root 21G May 23 17:53 /tmp/dummy.img
Michal Privoznik (32):
Introduce virStreamRecvFlags
Implement virStreamRecvFlags to some drivers
Introduce virStreamSkip
Introduce virStreamHoleSize
Introduce VIR_STREAM_RECV_STOP_AT_HOLE flag
Introduce virStreamSparseRecvAll
Introduce virStreamSparseSendAll
Introduce virStreamInData
virNetClientStreamNew: Track origin stream
Track if stream is skippable
RPC: Introduce virNetStreamSkip
Introduce VIR_NET_STREAM_SKIP message type
Teach wireshark plugin about VIR_NET_STREAM_SKIP
daemon: Introduce virNetServerProgramSendStreamSkip
virnetclientstream: Introduce virNetClientStreamSendSkip
daemon: Implement VIR_NET_STREAM_SKIP handling
virnetclientstream: Introduce virNetClientStreamHandleSkip
remote_driver: Implement virStreamSkip
virNetClientStreamRecvPacket: Introduce @flags argument
Introduce virNetClientStreamHoleSize
remote: Implement virStreamHoleSize
virNetClientStream: Wire up VIR_NET_STREAM_SKIP
remote_driver: Implement VIR_STREAM_RECV_STOP_AT_HOLE
daemonStreamHandleRead: Wire up seekable stream
fdstream: Implement seek
gendispatch: Introduce @sparseflag for our calls
Introduce virStorageVol{Download,Upload}Flags
virsh: Implement sparse stream to vol-download
virsh: Implement sparse stream to vol-upload
daemon: Don't call virStreamInData so often
fdstream: Suppress use of IO helper for sparse streams
storage: Enable sparse streams for virStorageVol{Download,Upload}
daemon/remote.c | 2 +-
daemon/stream.c | 147 +++++++++++-
daemon/stream.h | 3 +-
include/libvirt/libvirt-storage.h | 9 +
include/libvirt/libvirt-stream.h | 86 ++++++-
src/driver-stream.h | 23 ++
src/esx/esx_stream.c | 16 +-
src/fdstream.c | 117 ++++++++-
src/libvirt-storage.c | 4 +-
src/libvirt-stream.c | 454 +++++++++++++++++++++++++++++++++++
src/libvirt_internal.h | 3 +
src/libvirt_private.syms | 1 +
src/libvirt_public.syms | 10 +
src/libvirt_remote.syms | 3 +
src/remote/remote_driver.c | 89 ++++++-
src/remote/remote_protocol.x | 2 +
src/rpc/gendispatch.pl | 21 +-
src/rpc/virnetclient.c | 1 +
src/rpc/virnetclientstream.c | 203 +++++++++++++++-
src/rpc/virnetclientstream.h | 17 +-
src/rpc/virnetprotocol.x | 16 +-
src/rpc/virnetserverprogram.c | 33 +++
src/rpc/virnetserverprogram.h | 7 +
src/storage/storage_backend.c | 6 +-
src/storage/storage_driver.c | 4 +-
src/virnetprotocol-structs | 4 +
tools/virsh-volume.c | 49 ++--
tools/virsh.c | 93 +++++++
tools/virsh.h | 17 ++
tools/virsh.pod | 6 +-
tools/wireshark/src/packet-libvirt.c | 40 +++
tools/wireshark/src/packet-libvirt.h | 2 +
32 files changed, 1419 insertions(+), 69 deletions(-)
--
2.8.3
8 years, 7 months
[libvirt] [PATCH v2 0/8] PCI Multifunction device hotplug support
by Shivaprasad G Bhat
V1 was posted here.
http://www.redhat.com/archives/libvir-list/2016-May/msg01178.html
Changes from V1
Fixed couple of issues in address validation and assignment.
Added Rollback of the hotplug if anything fails in between.
Removed Patch 6 completely as it exposed way too many bugs. Changed the approach
a bit by introducing 2 new patches which take care of hostdevice preparation
and help reverting.
Todo:
1) Hardening the hotplug checks to disallow multifunction cards
hotplug as though they are single function cards.
2) Documentation update.
3) Test cases.
4) Should the events be delayed till all the functions are
hotplugged/unplugged? Something can fail and the revert may not be possible
Or the guest may refuse to free the device. If we show events
for those which got free, the rest of them may never be freed and also
that may not be usable by guest if the function 0 is not part of it. Need to
think more on this. Any suggestions ?
---
Shivaprasad G Bhat (8):
Revert "prevent hot unplugging multi function PCI device"
Release address in function granularity than slot
Validate address in virDomainPCIAddressReleaseAddr
Introduce PCI Multifunction device parser
Introduce virDomainPCIMultifunctionDeviceAddressAssign
Separate the hostdevice preparation and checks to a new funtion
Move the detach of PCI device to the beginnging of live hotplug
Enable PCI Multifunction hotplug/unplug
src/conf/domain_addr.c | 239 ++++++++++++++++++++++++++++--
src/conf/domain_addr.h | 4
src/conf/domain_conf.c | 236 +++++++++++++++++++++++++++++
src/conf/domain_conf.h | 22 +++
src/libvirt_private.syms | 5 +
src/qemu/qemu_domain_address.c | 2
src/qemu/qemu_driver.c | 321 ++++++++++++++++++++++++++++++++--------
src/qemu/qemu_hotplug.c | 161 ++++++++------------
src/qemu/qemu_hotplug.h | 5 +
9 files changed, 818 insertions(+), 177 deletions(-)
--
Signature
8 years, 7 months
[libvirt] [PATCH] storage: do not clear vols before volume upload
by Ján Tomko
Commit 5e54361c added virStoragePoolObjClearVols before refreshPool
to prevent duplicate volume entries.
However it is not needed here because we're not refreshing the pool yet,
just checking for the existence of the refresh callback.
The actual refresh is done via virStorageVolFDStreamCloseCb
in virStorageVolPoolRefreshThread, which already calls
virStoragePoolObjClearVols.
---
src/storage/storage_driver.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
index ce31e38..eb5f688 100644
--- a/src/storage/storage_driver.c
+++ b/src/storage/storage_driver.c
@@ -2353,15 +2353,14 @@ storageVolUpload(virStorageVolPtr obj,
/* If we have a refreshPool, use the callback routine in order to
* refresh the pool after the volume upload stream closes. This way
* we make sure the volume and pool data are refreshed without user
* interaction and we can just lookup the backend in the callback
* routine in order to call the refresh API.
*/
- virStoragePoolObjClearVols(pool);
if (backend->refreshPool) {
if (VIR_ALLOC(cbdata) < 0 ||
VIR_STRDUP(cbdata->pool_name, pool->def->name) < 0)
goto cleanup;
if (vol->target.type == VIR_STORAGE_VOL_PLOOP &&
VIR_STRDUP(cbdata->vol_path, vol->target.path) < 0)
goto cleanup;
--
2.7.3
8 years, 7 months
[libvirt] [PATCH 0/9] Deprecate more unused QEMU_CAPS
by Ján Tomko
Cleaning up after QEMU_CAPS_DEVICE I noticed QEMU_CAPS_DRIVE_READONLY
depends on it and QEMU_CAPS_PCIDEVICE did not really matter.
Ján Tomko (9):
qemu_command: assume QEMU_CAPS_DEVICE
qemu: assume QEMU_CAPS_DEVICE almost everywhere
tests: remove disk-drive-fat test
tests: remove <readonly/> from IDE disks
tests: always assume QEMU_CAPS_DRIVE_READONLY
qemu: always assume QEMU_CAPS_DRIVE_READONLY
Deprecate QEMU_CAPS_DRIVE_READONLY
Deprecate QEMU_CAPS_DEVICE
Deprecate QEMU_CAPS_PCIDEVICE
src/qemu/qemu_capabilities.c | 46 +--
src/qemu/qemu_capabilities.h | 6 +-
src/qemu/qemu_command.c | 425 ++++++---------------
src/qemu/qemu_command.h | 3 +-
src/qemu/qemu_domain.c | 6 +-
src/qemu/qemu_domain.h | 1 -
src/qemu/qemu_hostdev.c | 4 +-
src/qemu/qemu_hotplug.c | 61 +--
src/qemu/qemu_process.c | 8 +-
tests/qemucapabilitiesdata/caps_1.2.2.x86_64.xml | 2 -
tests/qemucapabilitiesdata/caps_1.3.1.x86_64.xml | 2 -
tests/qemucapabilitiesdata/caps_1.4.2.x86_64.xml | 2 -
tests/qemucapabilitiesdata/caps_1.5.3.x86_64.xml | 2 -
tests/qemucapabilitiesdata/caps_1.6.0.x86_64.xml | 2 -
tests/qemucapabilitiesdata/caps_1.6.50.x86_64.xml | 2 -
tests/qemucapabilitiesdata/caps_2.1.1.x86_64.xml | 2 -
tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml | 2 -
tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml | 2 -
.../caps_2.6.0-gicv2.aarch64.xml | 2 -
.../caps_2.6.0-gicv3.aarch64.xml | 2 -
tests/qemucapabilitiesdata/caps_2.6.0.ppc64le.xml | 2 -
tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml | 2 -
tests/qemuhelptest.c | 45 +--
tests/qemuhotplugtest.c | 2 -
.../qemuxml2argvdata/qemuxml2argv-boot-cdrom.args | 3 +-
.../qemuxml2argv-boot-complex-bootindex.args | 3 +-
.../qemuxml2argv-boot-complex.args | 3 +-
...xml2argv-boot-menu-disable-drive-bootindex.args | 3 +-
.../qemuxml2argv-boot-menu-disable-drive.args | 3 +-
.../qemuxml2argv-boot-menu-disable.args | 3 +-
...qemuxml2argv-boot-menu-enable-with-timeout.args | 3 +-
.../qemuxml2argv-boot-menu-enable.args | 3 +-
.../qemuxml2argvdata/qemuxml2argv-boot-multi.args | 3 +-
.../qemuxml2argvdata/qemuxml2argv-boot-order.args | 3 +-
.../qemuxml2argvdata/qemuxml2argv-boot-strict.args | 3 +-
.../qemuxml2argv-controller-order.args | 2 +-
tests/qemuxml2argvdata/qemuxml2argv-disk-aio.args | 2 +-
.../qemuxml2argv-disk-blockio.args | 3 +-
.../qemuxml2argv-disk-cdrom-empty.args | 2 +-
.../qemuxml2argv-disk-cdrom-network-ftp.args | 2 +-
.../qemuxml2argv-disk-cdrom-network-ftps.args | 2 +-
.../qemuxml2argv-disk-cdrom-network-http.args | 2 +-
.../qemuxml2argv-disk-cdrom-network-https.args | 2 +-
.../qemuxml2argv-disk-cdrom-network-tftp.args | 2 +-
...qemuxml2argv-disk-cdrom-tray-no-device-cap.args | 2 +-
.../qemuxml2argv-disk-cdrom-tray.args | 4 +-
.../qemuxml2argvdata/qemuxml2argv-disk-cdrom.args | 3 +-
.../qemuxml2argv-disk-copy_on_read.args | 2 +-
.../qemuxml2argv-disk-drive-boot-cdrom.args | 2 +-
.../qemuxml2argv-disk-drive-boot-disk.args | 2 +-
.../qemuxml2argv-disk-drive-cache-directsync.args | 2 +-
.../qemuxml2argv-disk-drive-cache-unsafe.args | 2 +-
.../qemuxml2argv-disk-drive-cache-v2-none.args | 2 +-
.../qemuxml2argv-disk-drive-cache-v2-wb.args | 2 +-
.../qemuxml2argv-disk-drive-cache-v2-wt.args | 2 +-
.../qemuxml2argv-disk-drive-discard.args | 2 +-
...uxml2argv-disk-drive-error-policy-enospace.args | 2 +-
.../qemuxml2argv-disk-drive-error-policy-stop.args | 2 +-
...gv-disk-drive-error-policy-wreport-rignore.args | 2 +-
.../qemuxml2argv-disk-drive-fat.args | 22 --
.../qemuxml2argv-disk-drive-fat.xml | 31 --
.../qemuxml2argv-disk-drive-fmt-qcow.args | 2 +-
.../qemuxml2argv-disk-drive-no-boot.args | 2 +-
.../qemuxml2argv-disk-drive-shared.args | 2 +-
.../qemuxml2argv-disk-ide-drive-split.args | 3 +-
.../qemuxml2argv-disk-ioeventfd.args | 2 +-
.../qemuxml2argvdata/qemuxml2argv-disk-order.args | 2 +-
.../qemuxml2argv-disk-scsi-disk-split.args | 6 +-
.../qemuxml2argv-disk-scsi-disk-vpd.args | 6 +-
.../qemuxml2argv-disk-scsi-disk-wwn.args | 3 +-
.../qemuxml2argv-disk-snapshot.args | 2 +-
.../qemuxml2argv-disk-source-pool-mode.args | 5 +-
.../qemuxml2argv-disk-source-pool.args | 5 +-
.../qemuxml2argvdata/qemuxml2argv-disk-virtio.args | 2 +-
tests/qemuxml2argvdata/qemuxml2argv-event_idx.args | 2 +-
.../qemuxml2argv-floppy-drive-fat.args | 2 +-
.../qemuxml2argv-graphics-spice-timeout.args | 2 +-
.../qemuxml2argv-hugepages-numa.args | 2 +-
.../qemuxml2argv-pci-autoadd-addr.args | 3 +-
.../qemuxml2argv-pci-autoadd-idx.args | 3 +-
tests/qemuxml2argvdata/qemuxml2argv-pci-many.args | 3 +-
.../qemuxml2argv-seclabel-dynamic-override.xml | 1 -
tests/qemuxml2argvtest.c | 43 +--
.../qemuxml2xmlout-seclabel-dynamic-override.xml | 1 -
tests/qemuxml2xmltest.c | 2 -
85 files changed, 246 insertions(+), 631 deletions(-)
delete mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-drive-fat.args
delete mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-drive-fat.xml
--
2.7.3
8 years, 7 months
Re: [libvirt] [PATCH] libxl: add .domainInterfaceAddresses
by Jim Fehlig
Chun Yan Liu wrote:
>
>>>> On 5/14/2016 at 07:47 AM, in message <5736677D.8030209(a)suse.com>, Jim Fehlig
> <jfehlig(a)suse.com> wrote:
>> On 05/13/2016 12:21 AM, Chunyan Liu wrote:
>>> Add .domainInterfaceAddresses so that user can have a way to
>>> get domain interface address by 'virsh domifaddr'. Currently
>>> it only supports '--source lease'.
>>>
>>> Signed-off: Chunyan Liu <cyliu(a)suse.com>
>>> ---
>>> src/libxl/libxl_driver.c | 140
>> +++++++++++++++++++++++++++++++++++++++++++++++
>>> 1 file changed, 140 insertions(+)
>>>
>>> diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
>>> index 062d6f8..f2bd6fa 100644
>>> --- a/src/libxl/libxl_driver.c
>>> +++ b/src/libxl/libxl_driver.c
>>> @@ -5425,6 +5425,145 @@ static int libxlNodeGetSecurityModel(virConnectPtr
>> conn,
>>> return 0;
>>> }
>>>
>>> +static int
>>> +libxlGetDHCPInterfaces(virDomainPtr dom,
>>> + virDomainObjPtr vm,
>>> + virDomainInterfacePtr **ifaces)
>>> +{
>>> + int rv = -1;
>>> + int n_leases = 0;
>>> + size_t i, j;
>>> + size_t ifaces_count = 0;
>>> + virNetworkPtr network = NULL;
>>> + char macaddr[VIR_MAC_STRING_BUFLEN];
>>> + virDomainInterfacePtr iface = NULL;
>>> + virNetworkDHCPLeasePtr *leases = NULL;
>>> + virDomainInterfacePtr *ifaces_ret = NULL;
>>> +
>>> + if (!dom->conn->networkDriver ||
>>> + !dom->conn->networkDriver->networkGetDHCPLeases) {
>>> + virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
>>> + _("Network driver does not support DHCP lease
>> query"));
>>> + return -1;
>>> + }
>>> +
>>> + for (i = 0; i < vm->def->nnets; i++) {
>>> + if (vm->def->nets[i]->type != VIR_DOMAIN_NET_TYPE_NETWORK)
>>> + continue;
>>> +
>>> + virMacAddrFormat(&(vm->def->nets[i]->mac), macaddr);
>>> + virObjectUnref(network);
>>> + network = virNetworkLookupByName(dom->conn,
>>> + vm->def->nets[i]->data.network.name);
>>> +
>>> + if ((n_leases = virNetworkGetDHCPLeases(network, macaddr,
>>> + &leases, 0)) < 0)
>>> + goto error;
>>> +
>>> + if (n_leases) {
>>> + if (VIR_EXPAND_N(ifaces_ret, ifaces_count, 1) < 0)
>>> + goto error;
>>> +
>>> + if (VIR_ALLOC(ifaces_ret[ifaces_count - 1]) < 0)
>>> + goto error;
>>> +
>>> + iface = ifaces_ret[ifaces_count - 1];
>>> + /* Assuming each lease corresponds to a separate IP */
>>> + iface->naddrs = n_leases;
>>> +
>>> + if (VIR_ALLOC_N(iface->addrs, iface->naddrs) < 0)
>>> + goto error;
>>> +
>>> + if (VIR_STRDUP(iface->name, vm->def->nets[i]->ifname) < 0)
>>> + goto cleanup;
>>> +
>>> + if (VIR_STRDUP(iface->hwaddr, macaddr) < 0)
>>> + goto cleanup;
>>> + }
>>> +
>>> + for (j = 0; j < n_leases; j++) {
>>> + virNetworkDHCPLeasePtr lease = leases[j];
>>> + virDomainIPAddressPtr ip_addr = &iface->addrs[j];
>>> +
>>> + if (VIR_STRDUP(ip_addr->addr, lease->ipaddr) < 0)
>>> + goto cleanup;
>>> +
>>> + ip_addr->type = lease->type;
>>> + ip_addr->prefix = lease->prefix;
>>> + }
>>> +
>>> + for (j = 0; j < n_leases; j++)
>>> + virNetworkDHCPLeaseFree(leases[j]);
>>> +
>>> + VIR_FREE(leases);
>>> + }
>>> +
>>> + *ifaces = ifaces_ret;
>>> + ifaces_ret = NULL;
>>> + rv = ifaces_count;
>>> +
>>> + cleanup:
>>> + virObjectUnref(network);
>>> + if (leases) {
>>> + for (i = 0; i < n_leases; i++)
>>> + virNetworkDHCPLeaseFree(leases[i]);
>>> + }
>>> + VIR_FREE(leases);
>>> +
>>> + return rv;
>>> +
>>> + error:
>>> + if (ifaces_ret) {
>>> + for (i = 0; i < ifaces_count; i++)
>>> + virDomainInterfaceFree(ifaces_ret[i]);
>>> + }
>>> + VIR_FREE(ifaces_ret);
>>> +
>>> + goto cleanup;
>>> +}
>>
>> It's unfortunate this is a copy-paste from the qemu driver. The code is not
>> trivial and any bug fixes in one copy could be missed in the other. A lot of
>> the
>> function is domain related, so probably can't be abstracted further to the
>> network code. Have you considered approaches that allow the drivers to share
>> this code?
>
> Well, it can be extracted and placed in bridge_driver.c as networkGetDHCPInterfaces,
> but I don't know if that is acceptable?
Hmm, maybe something like networkGetDHCPLeasesAll() is a better name. Regardless
of the name, I see that other functions in bridge_driver.c take a
virDomainDefPtr, so maybe extracting the code to bridge_driver.c is acceptable.
Laine (cc'd) is generally regarded as the libvirt networking expert :-). Let's
see if he has an opinion.
Regards,
Jim
8 years, 7 months
[libvirt] [PATCH] util: compilation fix if build without GNUTLS library
by Mikhail Feoktistov
---
src/util/vircrypto.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/src/util/vircrypto.c b/src/util/vircrypto.c
index 5183d49..4f288f0 100644
--- a/src/util/vircrypto.c
+++ b/src/util/vircrypto.c
@@ -24,6 +24,7 @@
#include "virlog.h"
#include "virerror.h"
#include "viralloc.h"
+#include "virrandom.h"
#include "md5.h"
#include "sha256.h"
@@ -220,14 +221,14 @@ virCryptoEncryptDataAESgnutls(gnutls_cipher_algorithm_t gnutls_enc_alg,
*/
int
virCryptoEncryptData(virCryptoCipher algorithm,
- uint8_t *enckey,
+ uint8_t *enckey ATTRIBUTE_UNUSED,
size_t enckeylen,
- uint8_t *iv,
+ uint8_t *iv ATTRIBUTE_UNUSED,
size_t ivlen,
- uint8_t *data,
- size_t datalen,
- uint8_t **ciphertext,
- size_t *ciphertextlen)
+ uint8_t *data ATTRIBUTE_UNUSED,
+ size_t datalen ATTRIBUTE_UNUSED,
+ uint8_t **ciphertext ATTRIBUTE_UNUSED,
+ size_t *ciphertextlen ATTRIBUTE_UNUSED)
{
switch (algorithm) {
case VIR_CRYPTO_CIPHER_AES256CBC:
--
1.8.3.1
8 years, 7 months
[libvirt] [PATCH 0/4] Couple of random and crypto adjustments
by John Ferlan
Patches 1&2 alter the virRandomBytes to accomodate the lone holdout code
that was using /dev/urandom directly to add a range of bytes that are
acceptible returns for the caller.
Patches 3&4 modify the virCryptoEncryptData algorithm to "A" (hopefully)
build right in a non gnutls environment and "B" make it so there future
adjustments won't be doing cut, copy, & paste based on the key size and
whether the iv is required.
If AES192CBC were added the first two parameters to the DO_CRYPT macro
would be 24, 16, while AES192CBC would have 16, 16.
John Ferlan (4):
util: Add range parameters to virRandomBytes
storage: Use virRandomBytes for virStorageGenerateQcowPassphrase
util: Alter virCryptoEncryptData for non GNUTLS builds
util: Adjust virCryptoEncryptData code to use macros
src/storage/storage_backend.c | 10 +++--
src/util/vircrypto.c | 88 +++++++++++++++++++++++++----------------
src/util/virrandom.c | 13 ++++--
src/util/virrandom.h | 3 +-
src/util/virstorageencryption.c | 42 +++++++-------------
src/util/virstorageencryption.h | 4 +-
src/util/viruuid.c | 2 +-
tests/qemuxml2argvmock.c | 2 +-
tests/vircryptotest.c | 4 +-
tests/virrandommock.c | 10 +++--
tests/virrandomtest.c | 32 +++++++++++----
11 files changed, 124 insertions(+), 86 deletions(-)
--
2.5.5
8 years, 7 months