[libvirt] [PATCH] Fix potential crash when setting partial cpu/memory/numa/interface limits on domains
by Brian Rak
The number of parameters in new_params is not guaranteed to be the same as the number of parameters in params. Use the correct count when freeing new_params to avoid crashes
---
libvirt-override.c | 24 ++++++++++++------------
1 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/libvirt-override.c b/libvirt-override.c
index 9dc6ad4..3fa9b9b 100644
--- a/libvirt-override.c
+++ b/libvirt-override.c
@@ -914,7 +914,7 @@ libvirt_virDomainSetSchedulerParameters(PyObject *self ATTRIBUTE_UNUSED,
int i_retval;
int nparams = 0;
Py_ssize_t size = 0;
- virTypedParameterPtr params, new_params = NULL;
+ virTypedParameterPtr params = NULL, new_params = NULL;
if (!PyArg_ParseTuple(args, (char *)"OO:virDomainSetScedulerParameters",
&pyobj_domain, &info))
@@ -973,7 +973,7 @@ libvirt_virDomainSetSchedulerParameters(PyObject *self ATTRIBUTE_UNUSED,
cleanup:
virTypedParamsFree(params, nparams);
- virTypedParamsFree(new_params, nparams);
+ virTypedParamsFree(new_params, size);
return ret;
}
@@ -1064,7 +1064,7 @@ libvirt_virDomainSetBlkioParameters(PyObject *self ATTRIBUTE_UNUSED,
int nparams = 0;
Py_ssize_t size = 0;
unsigned int flags;
- virTypedParameterPtr params, new_params = NULL;
+ virTypedParameterPtr params = NULL, new_params = NULL;
if (!PyArg_ParseTuple(args,
(char *)"OOi:virDomainSetBlkioParameters",
@@ -1123,7 +1123,7 @@ libvirt_virDomainSetBlkioParameters(PyObject *self ATTRIBUTE_UNUSED,
cleanup:
virTypedParamsFree(params, nparams);
- virTypedParamsFree(new_params, nparams);
+ virTypedParamsFree(new_params, size);
return ret;
}
@@ -1184,7 +1184,7 @@ libvirt_virDomainSetMemoryParameters(PyObject *self ATTRIBUTE_UNUSED,
int nparams = 0;
Py_ssize_t size = 0;
unsigned int flags;
- virTypedParameterPtr params, new_params = NULL;
+ virTypedParameterPtr params = NULL, new_params = NULL;
if (!PyArg_ParseTuple(args,
(char *)"OOi:virDomainSetMemoryParameters",
@@ -1243,7 +1243,7 @@ libvirt_virDomainSetMemoryParameters(PyObject *self ATTRIBUTE_UNUSED,
cleanup:
virTypedParamsFree(params, nparams);
- virTypedParamsFree(new_params, nparams);
+ virTypedParamsFree(new_params, size);
return ret;
}
@@ -1304,7 +1304,7 @@ libvirt_virDomainSetNumaParameters(PyObject *self ATTRIBUTE_UNUSED,
int nparams = 0;
Py_ssize_t size = 0;
unsigned int flags;
- virTypedParameterPtr params, new_params = NULL;
+ virTypedParameterPtr params = NULL, new_params = NULL;
if (!PyArg_ParseTuple(args,
(char *)"OOi:virDomainSetNumaParameters",
@@ -1363,7 +1363,7 @@ libvirt_virDomainSetNumaParameters(PyObject *self ATTRIBUTE_UNUSED,
cleanup:
virTypedParamsFree(params, nparams);
- virTypedParamsFree(new_params, nparams);
+ virTypedParamsFree(new_params, size);
return ret;
}
@@ -1425,7 +1425,7 @@ libvirt_virDomainSetInterfaceParameters(PyObject *self ATTRIBUTE_UNUSED,
Py_ssize_t size = 0;
unsigned int flags;
const char *device = NULL;
- virTypedParameterPtr params, new_params = NULL;
+ virTypedParameterPtr params = NULL, new_params = NULL;
if (!PyArg_ParseTuple(args,
(char *)"OzOi:virDomainSetInterfaceParameters",
@@ -1484,7 +1484,7 @@ libvirt_virDomainSetInterfaceParameters(PyObject *self ATTRIBUTE_UNUSED,
cleanup:
virTypedParamsFree(params, nparams);
- virTypedParamsFree(new_params, nparams);
+ virTypedParamsFree(new_params, size);
return ret;
}
@@ -4782,7 +4782,7 @@ libvirt_virDomainSetBlockIoTune(PyObject *self ATTRIBUTE_UNUSED,
Py_ssize_t size = 0;
const char *disk;
unsigned int flags;
- virTypedParameterPtr params, new_params = NULL;
+ virTypedParameterPtr params = NULL, new_params = NULL;
if (!PyArg_ParseTuple(args, (char *)"OzOi:virDomainSetBlockIoTune",
&pyobj_domain, &disk, &info, &flags))
@@ -4840,7 +4840,7 @@ libvirt_virDomainSetBlockIoTune(PyObject *self ATTRIBUTE_UNUSED,
cleanup:
virTypedParamsFree(params, nparams);
- virTypedParamsFree(new_params, nparams);
+ virTypedParamsFree(new_params, size);
return ret;
}
--
1.7.1
10 years, 7 months
[libvirt] [PATCH] Fix snapshot-create-as in man page
by shyu
Fix bug https://bugzilla.redhat.com/show_bug.cgi?id=1080859 about
snapshot type in man page. Snapshot type should be no, internal, or
external
---
tools/virsh.pod | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/virsh.pod b/tools/virsh.pod
index 20352cb..ba2da20 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -3070,7 +3070,7 @@ is specified, the snapshot will not include vm state.
The I<--memspec> option can be used to control whether a checkpoint
is internal or external. The I<--memspec> flag is mandatory, followed
by a B<memspec> of the form B<[file=]name[,snapshot=type]>, where
-type can be B<none>, B<internal>, or B<external>. To include a literal
+type can be B<no>, B<internal>, or B<external>. To include a literal
comma in B<file=name>, escape it with a second comma. I<--memspec> cannot
be used together with I<--disk-only>.
--
1.8.5.3
10 years, 7 months
[libvirt] [PATCH 0/2] ESX: Implement virDomainScreenshot
by Dawid Zamirski
Hello,
The following patches implement virDomainScreenshot for the ESX driver.
The screenshot VI API call was added in version 4.0, therefore, I had to
make changes to esx_vi_generator.py in order to allow VI method calls for
versions newer than 2.5. This was done by adding an optional "apiVersion"
token to the method header definition in the .input file. If it is not
specified, "2.5" will be used so existing VI calls will work "as is"
without any code updates.
Regards,
Dawid Zamirski (2):
ESX: Allow method calls for VI version > 2.5
ESX: Implement virDomainScreenshot
src/esx/esx_driver.c | 173 +++++++++++++++++++++++++++++++++++++++++
src/esx/esx_vi.c | 26 ++++++-
src/esx/esx_vi.h | 2 +-
src/esx/esx_vi_generator.input | 19 ++++-
src/esx/esx_vi_generator.py | 20 +++--
src/esx/esx_vi_methods.c | 12 +--
6 files changed, 238 insertions(+), 14 deletions(-)
--
1.9.0
10 years, 7 months
[libvirt] [PATCH] ESX: Add support for virtualHW version 10
by Dawid Zamirski
This follows the same pattern when v8 and v9 were added. I've tested
this with my ESX 5.5 and seems to work fine.
---
src/vmx/vmx.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c
index 32ddd05..5dc9925 100644
--- a/src/vmx/vmx.c
+++ b/src/vmx/vmx.c
@@ -49,6 +49,7 @@ domain-xml <=> vmx
virtualHW.version = "7" # essential for ESX 4.0
virtualHW.version = "8" # essential for ESX 5.0
virtualHW.version = "9" # essential for ESX 5.1
+ virtualHW.version = "10" # essential for ESX 5.5
??? <=> guestOS = "<value>" # essential, FIXME: not representable
@@ -1316,10 +1317,11 @@ virVMXParseConfig(virVMXContext *ctx,
}
if (virtualHW_version != 4 && virtualHW_version != 7 &&
- virtualHW_version != 8 && virtualHW_version != 9) {
+ virtualHW_version != 8 && virtualHW_version != 9 &&
+ virtualHW_version != 10) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Expecting VMX entry 'virtualHW.version' to be "
- "4, 7, 8 or 9 but found %lld"),
+ "4, 7, 8, 9 or 10 but found %lld"),
virtualHW_version);
goto cleanup;
}
--
1.9.0
10 years, 7 months
[libvirt] [PATCH 0/5] Another attempt at improving virsh autocompletion
by Solly Ross
This patch set represents yet another attempt to improve the virsh
autocompletion. When writing this patch, I tried to take into account
the comments on the previous attempt at autocompletion by Tomas Meszaros.
Specifically, it was reccomended that any completion use the existing
methods that virsh has in place to parse the partial line being completed.
When doing so, I found that I was duplicating a significant portion of the
code in vshCommandParse. Since the comments on Tomas's code suggested
refactoring common code into a separate function, I attempted to do
so with vshCommandParse. One of the primary issues with simply just
moving the parsing logic from vshCommandParse into a separate function
was that vshCommandParse throws errors when it encounters unknown or
invalid information. While this is the correct behavior for parsing
a command to be executed, it is not appropriate for autocompletion.
Essentially, the new function represents one iteration of the main
loop from vshCommandParse. However, instead of constructing a parsed
option or command object at the end, or returning errors, it returns
a "state" value and sets pointers. Then, a calling function may choose
to deal with the state values (like vshCommandParse) or ignore most of
the state values (like the completion code, which ignores most state
and errors, as it is just interested in which flags have already been
used). This is perhaps the most "dangerous" and controversial part
of the patch set, so I figured I'd get some feedback before progressing
any further.
The other significant changes in the patch set (besides richer
completion support) are as follows:
- completion no longer automatically falls back to readline's
default filename completion. Instead, if filename completion
is desired, an option may be explicitly marked as requiring
filename completion.
- when readline support is enable, a global vshControl object
is made available by way of a macro/function. When readline
support is disabled, the global is not included and the macro
simply returns NULL. This global is required for smart completers.
- the code which is used by the "list" command has been moved
from virsh-domain-monitor to virsh-completer. This way,
it is accessible to both the "list" command code and
the domain completer.
Note that none of the options which use the domain completer
currently have flags set to indicate whether active or inactive
domains should be completed. If this completion patch-set is
OKed, then I will go back and add these flags. Currently,
the commit is there simply to make testing out the new completion
easier.
Solly Ross (5):
Improve virsh autocompletion (extract parser)
Improve virsh autocompletion (base framework)
Improve virsh autocompletion (global ctl object)
Improve virsh autocompletion (domain completer)
Improve virsh autocompletion (enum completer macro)
outgoing/0000-cover-letter.patch | 68 +
...prove-virsh-autocompletion-extract-parser.patch | 428 ++++++
...prove-virsh-autocompletion-base-framework.patch | 278 ++++
...ve-virsh-autocompletion-global-ctl-object.patch | 116 ++
...ove-virsh-autocompletion-domain-completer.patch | 1479 ++++++++++++++++++++
...virsh-autocompletion-enum-completer-macro.patch | 131 ++
tools/Makefile.am | 3 +-
tools/virsh-completer.c | 353 +++++
tools/virsh-completer.h | 86 ++
tools/virsh-domain-monitor.c | 287 +---
tools/virsh-domain.c | 72 +
tools/virsh-snapshot.c | 11 +
tools/virsh.c | 517 +++++--
tools/virsh.h | 13 +
14 files changed, 3447 insertions(+), 395 deletions(-)
create mode 100644 outgoing/0000-cover-letter.patch
create mode 100644 outgoing/0001-Improve-virsh-autocompletion-extract-parser.patch
create mode 100644 outgoing/0002-Improve-virsh-autocompletion-base-framework.patch
create mode 100644 outgoing/0003-Improve-virsh-autocompletion-global-ctl-object.patch
create mode 100644 outgoing/0004-Improve-virsh-autocompletion-domain-completer.patch
create mode 100644 outgoing/0005-Improve-virsh-autocompletion-enum-completer-macro.patch
create mode 100644 tools/virsh-completer.c
create mode 100644 tools/virsh-completer.h
--
1.8.3.2
10 years, 7 months
[libvirt] [PATCH]execute netdev_del after receive DEVICE_DELETED event
by x00221466
Hi,
When live detaching the virtual net device, such as virtio nic、
RTL8139、E1000, there are some problems:
(1)If the Guest OS don't support the hot plugging pci device, detach
the virtual network device by Libvirt, the "net device" in Qemu will
still exist, but "hostnet"(tap) in Qemu will be removed. so the net device
in Guest OS will be of no effect.
(2)If reject the nic in Guest OS, Qemu will remove the "net device",
then Qemu send DEVICE_DELETED to Libvirt, Libvirt receive the event
in event-loop thread and release info of the net device in
qemuDomainRemoveNetDevice func. but "hostnet" in Qemu still exist.
So next live attaching virtual net device will be failed because of
"Duplicate ID".
#virsh attach-device win2008_st_r2_64 net.xml --live
error: Failed to attach device from net.xml
error: internal error: unable to execute QEMU command 'netdev_add':
Duplicate ID 'hostnet0' for netdev
(3)In addition, in qemuDomainDetachNetDevice, detach net device func,
"netdev_del" command will be sent after sending "device_del" command
at once. So it is violent to remove the tap device before the net device
is completely removed.
So I think it's more logical that doing the work of sending Qemu command
"netdev_del" after receive the DEVICE_DELETED event. It can avoid the conflict
of device info between Libvirt side and Qemu side.
I create a thread in qemuDomainRemoveDevice,the handle of DEVICE_DELETED event,
to execute QEMU command "netdev_del".
Regards,
-xie
Signed-off-by: xiexiangyou <xiexiangyou(a)huawei.com>
---
src/qemu/qemu_hotplug.c | 154 +++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 137 insertions(+), 17 deletions(-)
diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
index bf4f160..81f6a56 100644
--- a/src/qemu/qemu_hotplug.c
+++ b/src/qemu/qemu_hotplug.c
@@ -2699,6 +2699,124 @@ qemuDomainRemoveChrDevice(virQEMUDriverPtr driver,
virDomainChrDefFree(chr);
}
+typedef struct privVmDevDriver {
+ virQEMUDriverPtr driver;
+ virDomainObjPtr vm;
+ virDomainDeviceDefPtr dev;
+}privVmDevDriver, *privVmDevDriverPtr;
+
+static void
+qemuProcessRemoveNetDevice(void *opaque)
+{
+ privVmDevDriverPtr privData = opaque;
+ virQEMUDriverPtr driver = privData->driver;
+ virDomainObjPtr vm = privData->vm;
+ virDomainDeviceDefPtr dev = privData->dev;
+
+ qemuDomainObjPrivatePtr priv = vm->privateData;
+ char mac[VIR_MAC_STRING_BUFLEN];
+ int detachidx;
+ virDomainNetDefPtr detach = NULL;
+ char *hostnet_name = NULL;
+ int vlan;
+
+ virObjectLock(vm);
+
+ if (qemuDomainObjBeginJob(driver, vm, QEMU_JOB_MODIFY) < 0)
+ goto cleanup;
+
+ detachidx = virDomainNetFindIdx(vm->def, dev->data.net);
+ if (detachidx == -2) {
+ virReportError(VIR_ERR_OPERATION_FAILED,
+ _("multiple devices matching mac address %s found"),
+ virMacAddrFormat(&dev->data.net->mac, mac));
+ goto endjob;
+ }
+ else if (detachidx < 0) {
+ virReportError(VIR_ERR_OPERATION_FAILED,
+ _("network device %s not found"),
+ virMacAddrFormat(&dev->data.net->mac, mac));
+ goto endjob;
+ }
+ detach = vm->def->nets[detachidx];
+ if (virAsprintf(&hostnet_name, "host%s", detach->info.alias) < 0) {
+ virReportOOMError();
+ goto endjob;
+ }
+ if ((vlan = qemuDomainNetVLAN(detach)) < 0) {
+ virReportError(VIR_ERR_OPERATION_FAILED,
+ "%s", _("unable to determine original VLAN"));
+ goto endjob;
+ }
+
+ qemuDomainObjEnterMonitor(driver, vm);
+ if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_NETDEV) &&
+ virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
+ if (qemuMonitorRemoveNetdev(priv->mon, hostnet_name) < 0) {
+ qemuDomainObjExitMonitor(driver, vm);
+ virDomainAuditNet(vm, detach, NULL, "detach", false);
+ goto endjob;
+ }
+ } else {
+ if (qemuMonitorRemoveHostNetwork(priv->mon, vlan, hostnet_name) < 0) {
+ qemuDomainObjExitMonitor(driver, vm);
+ virDomainAuditNet(vm, detach, NULL, "detach", false);
+ goto endjob;
+ }
+ }
+ qemuDomainObjExitMonitor(driver, vm);
+
+ qemuDomainRemoveNetDevice(driver, vm, dev->data.net);
+
+endjob:
+ if (!qemuDomainObjEndJob(driver, vm))
+ vm = NULL;
+
+cleanup:
+ VIR_FREE(hostnet_name);
+ VIR_FREE(privData->dev);
+ VIR_FREE(privData);
+
+ if (vm && virObjectUnref(vm))
+ virObjectUnlock(vm);
+}
+
+static void
+qemuRemoveNetDeviceJob(virQEMUDriverPtr driver,
+ virDomainObjPtr vm,
+ virDomainDeviceDefPtr dev)
+{
+ virThread th;
+ privVmDevDriverPtr data = NULL;
+ virDomainDeviceDefPtr device = NULL;
+
+ if (VIR_ALLOC(data) < 0) {
+ VIR_ERROR(_("Failed to alloc VmDevDriver"));
+ return;
+ }
+
+ if (VIR_ALLOC(device) < 0) {
+ VIR_ERROR(_("Failed to alloc virDomainDeviceDefPtr"));
+ VIR_FREE(data);
+ return;
+ }
+ memcpy(device, dev, sizeof(*device));
+
+ data->dev = device;
+ data->driver = driver;
+ data->vm = vm;
+ virObjectRef(vm);
+ if (virThreadCreate(&th,
+ false,
+ qemuProcessRemoveNetDevice,
+ data) < 0) {
+ VIR_ERROR(_("Failed to create remove net device thread"));
+ VIR_FREE(device);
+ VIR_FREE(data);
+ virObjectUnref(vm);
+ }
+
+}
void
qemuDomainRemoveDevice(virQEMUDriverPtr driver,
@@ -2713,7 +2831,7 @@ qemuDomainRemoveDevice(virQEMUDriverPtr driver,
qemuDomainRemoveControllerDevice(driver, vm, dev->data.controller);
break;
case VIR_DOMAIN_DEVICE_NET:
- qemuDomainRemoveNetDevice(driver, vm, dev->data.net);
+ qemuRemoveNetDeviceJob(driver, vm, dev);
break;
case VIR_DOMAIN_DEVICE_HOSTDEV:
qemuDomainRemoveHostDevice(driver, vm, dev->data.hostdev);
@@ -3419,26 +3537,28 @@ qemuDomainDetachNetDevice(virQEMUDriverPtr driver,
goto cleanup;
}
}
+ qemuDomainObjExitMonitor(driver, vm);
- if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_NETDEV) &&
- virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
- if (qemuMonitorRemoveNetdev(priv->mon, hostnet_name) < 0) {
- qemuDomainObjExitMonitor(driver, vm);
- virDomainAuditNet(vm, detach, NULL, "detach", false);
- goto cleanup;
- }
- } else {
- if (qemuMonitorRemoveHostNetwork(priv->mon, vlan, hostnet_name) < 0) {
- qemuDomainObjExitMonitor(driver, vm);
- virDomainAuditNet(vm, detach, NULL, "detach", false);
- goto cleanup;
+ if (!qemuDomainWaitForDeviceRemoval(vm)) {
+ qemuDomainObjEnterMonitor(driver, vm);
+ if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_NETDEV) &&
+ virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
+ if (qemuMonitorRemoveNetdev(priv->mon, hostnet_name) < 0) {
+ qemuDomainObjExitMonitor(driver, vm);
+ virDomainAuditNet(vm, detach, NULL, "detach", false);
+ goto cleanup;
+ }
+ } else {
+ if (qemuMonitorRemoveHostNetwork(priv->mon, vlan, hostnet_name) < 0) {
+ qemuDomainObjExitMonitor(driver, vm);
+ virDomainAuditNet(vm, detach, NULL, "detach", false);
+ goto cleanup;
+ }
}
- }
- qemuDomainObjExitMonitor(driver, vm);
+ qemuDomainObjExitMonitor(driver, vm);
- if (!qemuDomainWaitForDeviceRemoval(vm))
qemuDomainRemoveNetDevice(driver, vm, detach);
-
+ }
ret = 0;
cleanup:
--
1.6.0.2
10 years, 7 months
[libvirt] [PATCH] Fix virNodeDeviceListCaps always returns empty
by Jincheng Miao
virNodeDeviceListCaps will always return empty for a pci nodedevice,
actually it should return 'pci'.
It is because the loop variable ncaps isn't increased.
https://bugzilla.redhat.com/show_bug.cgi?id=1081932
Signed-off-by: Jincheng Miao <jmiao(a)redhat.com>
---
src/node_device/node_device_driver.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c
index 1f3a083..6906463 100644
--- a/src/node_device/node_device_driver.c
+++ b/src/node_device/node_device_driver.c
@@ -420,7 +420,7 @@ nodeDeviceListCaps(virNodeDevicePtr dev, char **const names, int maxnames)
goto cleanup;
for (caps = obj->def->caps; caps && ncaps < maxnames; caps = caps->next) {
- if (VIR_STRDUP(names[ncaps], virNodeDevCapTypeToString(caps->type)) < 0)
+ if (VIR_STRDUP(names[ncaps++], virNodeDevCapTypeToString(caps->type)) < 0)
goto cleanup;
}
ret = ncaps;
--
1.8.2.1
10 years, 7 months
[libvirt] [PATCH v5 for 2.0 0/3] ABI change: change group name of option table to match with option name
by Amos Kong
This patchset changes group names of option tables to match with option name,
this breakes ABI, release note was updated.
V4: fix tpmdev, add name matching test (markus)
V5: adjust patch order (paolo)
Amos Kong (3):
only add qemu_tpmdev_opts when CONFIG_TPM is defined
update names in option tables to match with actual command-line
spelling
abort QEMU if group name in option table doesn't match with defined
option name
hw/acpi/core.c | 8 ++++----
hw/nvram/fw_cfg.c | 4 ++--
include/qemu/option.h | 2 +-
qemu-options.h | 12 ++++++++++++
util/qemu-config.c | 28 ++++++++++++++++++++++++++++
vl.c | 37 +++++++++++++------------------------
6 files changed, 60 insertions(+), 31 deletions(-)
--
1.8.5.3
10 years, 7 months