[libvirt] [PATCH 00/13] qemu: fix device alias usage, ide controllers, scsi options
by Laine Stump
These are intertwined a bit, hence they are all posted in the same series.
This started out with the intent to generate an error/failure on
request for an IDE controller on a machinetype that doesn't support
IDE (currently anything except 440fx-based machinetypes), or a 2nd IDE
controller on a machinetype that only supports one (i.e. 440fx). This
led to a few other related fixes, and some "fixes related to the
related fixes":
* 1 and 2 just eliminate redundant code that I found while
making the changes.
* 3 & 4 change two sets of if else if else if, into switches,
so that it's cleaner and simpler to add more cases.
* 5 is a utility function that will be used later to make it easier to
get the alias of the controller required by a particular device.
* 6 adds exceptions for the primary IDE on 440fx and primary SATA on
q35 to the function that creates controller alias names (since those
are hardcoded in qemu)
* 7-9 switch all remaining uses of BufferAsprintf(buf,
"blahcontroller%d") with calls to the function that returns the
*real* alias of the controller device.
* 10 removes a test that verifies we allow an IDE controller in an
s390 machine definition, and renames the tests to indicate that
although we're checking to make sure we allow usb controllers on
s390, that this isn't actually a valid config. (I would add a
warning in the appropriate place when this happens, but at the
moment I'm sick of looking at the problem :-/) - This is v2 of the
following patch that I posted by itself earlier:
https://www.redhat.com/archives/libvir-list/2015-April/msg01596.html
https://www.redhat.com/archives/libvir-list/2015-May/msg00031.html
* 11 makes it an error to define an IDE controller that qemu won't be
able to actually create.
* 12 and 13 fix two additional prolems I noticed with the creation of
device and drive strings for SCSI disks - the first is that we add a
"channel=" option even when qemu has told us it doesn't support it,
and the 2nd is that we have carried forward a restriction that bus
must == 0 for SCSI - this check was added in 2009, and it seems that
it is only valid when *not* using -device to define the disk
parameters.
Laine Stump (13):
qemu: use qemuDomainMachineIsI440FX() in appropriate place
qemu: eliminate duplicated code in qemuBuildDriveDevStr()
qemu: change if to switch in qemuBuildDeviceAddressStr
qemu: restructure qemuAssignDeviceControllerAlias
conf: utility to return alias of a controller based on type/index
qemu: add exceptions for alias names of primary sata/ide controllers
qemu: use controller alias when constructing disk/controller args
qemu: use alias for all controller ids in qemuBuildControllerDevStr
qemu: use controller object alias in commandline for virtio-serial
device
qemu: remove test for allowing ide controller in s390, rename usb
tests
qemu: log error when domain has an upsupported IDE controller
qemu: only add channel arg to scsi-disk if qemu binary supports it
qemu: allow bus != 0 for scsi-disk when -device is used
src/conf/domain_conf.c | 34 +++
src/conf/domain_conf.h | 3 +
src/libvirt_private.syms | 1 +
src/qemu/qemu_command.c | 314 ++++++++++++---------
src/qemu/qemu_command.h | 3 +-
src/qemu/qemu_hotplug.c | 4 +-
.../qemuxml2argv-disk-blockio.args | 2 +-
.../qemuxml2argvdata/qemuxml2argv-disk-blockio.xml | 1 -
.../qemuxml2argv-disk-drive-network-iscsi-lun.args | 2 +-
.../qemuxml2argv-disk-ide-drive-split.args | 2 +-
.../qemuxml2argv-disk-ide-drive-split.xml | 1 -
.../qemuxml2argv-disk-sata-device.args | 4 +-
.../qemuxml2argv-disk-scsi-disk-split.args | 8 +-
.../qemuxml2argv-disk-scsi-disk-vpd.args | 2 +-
.../qemuxml2argv-disk-scsi-disk-wwn.args | 4 +-
.../qemuxml2argv-disk-scsi-lun-passthrough.args | 12 +-
.../qemuxml2argv-disk-scsi-lun-passthrough.xml | 4 +-
.../qemuxml2argv-disk-scsi-megasas.args | 2 +-
.../qemuxml2argv-disk-scsi-virtio-scsi.args | 2 +-
.../qemuxml2argv-disk-scsi-vscsi.args | 2 +-
.../qemuxml2argv-disk-source-pool-mode.args | 2 +-
.../qemuxml2argv-disk-source-pool-mode.xml | 1 -
.../qemuxml2argv-disk-source-pool.args | 2 +-
.../qemuxml2argv-disk-source-pool.xml | 1 -
.../qemuxml2argv-disk-virtio-scsi-ccw.args | 2 +-
.../qemuxml2argv-disk-virtio-scsi-cmd_per_lun.args | 2 +-
.../qemuxml2argv-disk-virtio-scsi-max_sectors.args | 2 +-
.../qemuxml2argv-disk-virtio-scsi-num_queues.args | 2 +-
.../qemuxml2argv-pseries-vio-user-assigned.args | 2 +-
.../qemuxml2argvdata/qemuxml2argv-pseries-vio.args | 2 +-
...uxml2argv-s390-allow-bogus-usb-controller.args} | 0
...muxml2argv-s390-allow-bogus-usb-controller.xml} | 3 -
...=> qemuxml2argv-s390-allow-bogus-usb-none.args} | 0
... => qemuxml2argv-s390-allow-bogus-usb-none.xml} | 0
tests/qemuxml2argvtest.c | 29 +-
.../qemuxml2xmlout-disk-source-pool.xml | 1 -
36 files changed, 266 insertions(+), 192 deletions(-)
rename tests/qemuxml2argvdata/{qemuxml2argv-s390-piix-controllers.args => qemuxml2argv-s390-allow-bogus-usb-controller.args} (100%)
rename tests/qemuxml2argvdata/{qemuxml2argv-s390-piix-controllers.xml => qemuxml2argv-s390-allow-bogus-usb-controller.xml} (86%)
rename tests/qemuxml2argvdata/{qemuxml2argv-s390-usb-none.args => qemuxml2argv-s390-allow-bogus-usb-none.args} (100%)
rename tests/qemuxml2argvdata/{qemuxml2argv-s390-usb-none.xml => qemuxml2argv-s390-allow-bogus-usb-none.xml} (100%)
--
2.1.0
9 years, 6 months
[libvirt] Windows Development
by scott lee
I am experimenting with libvirt, and my favorite IDE is visual studio so I
looked for an easy method to build the libvirt library on windows and found
that the state of cross-platform libraries like Mingw are outdated or
difficult to use correctly for developers who want to start coding
immediatly with libvirt. I know there is a way, but assembling the right
libraries and commands was just too much. So, I found that the libvirt
dll’s are actually a part of most distros of linux and can be downloaded
and extracted. I just needed to find out what dlls were needed, then search
the repos for those files.
After the search, I have begun work on a powershell script to get the
latest libvirt builds from fedora, download and extract them. After that,
you can go to town building libraries against the libvirt api. Check out
the script here: https://github.com/smasherprog/Libvirt_Windows_Dll
Anyone who links against the libvirt library would be creating a management
tool of some sort so a language like C# so after I create this tool, I will
write some code to generate the C# code files for the DLLImport calls. The
Libvirt header thousands of lines long so I will write some code to extract
the calls/structs and generate the PInvoke calls for everything at once and
place it into a .cs file so developers can start dewveloping in libvirt
fast and easy.
Scott Lee
9 years, 6 months
[libvirt] [PATCH 0/4] Misc clean-ups again
by Martin Kletzander
Just a couple of them this time.
Martin Kletzander (4):
rpc: Don't mix max_clients and max_workers in PostExecRestart
virnetserver: Remove unnecessary double space
gendispatch: Don't generate long lines
Some alignment fixes in lxc_controller and jsontest
src/lxc/lxc_controller.c | 16 ++++++++--------
src/rpc/gendispatch.pl | 5 +++--
src/rpc/virnetserver.c | 6 +++---
tests/jsontest.c | 12 ++++++------
4 files changed, 20 insertions(+), 19 deletions(-)
--
2.4.0
9 years, 6 months
[libvirt] [PATCH 0/2] Clear iothreadid autofill flag for two instances
by John Ferlan
https://bugzilla.redhat.com/show_bug.cgi?id=1218577
The first patch considers the philosophy of the bug report with respect
to thread deletion, but doesn't resolve it completely since the ordering
of when iothreadpin is done is important. For this patch, when an iothreadid
is removed from the "beginning" or "middle" of the iothreadid list, then
clear the autofill flag unconditionally for all subsequent iothreadid's.
The second patch specifically clears the autofill flag when iothreadpin
is used treating it as if someone added an IOThread via iothreadadd
John Ferlan (2):
conf: Expose iothreadids when delete non sequential iothreadids
qemu: Clear autofil fill flag when pinning iothread
src/conf/domain_conf.c | 19 ++++++++++++++-----
src/qemu/qemu_driver.c | 2 ++
2 files changed, 16 insertions(+), 5 deletions(-)
--
2.1.0
9 years, 6 months
[libvirt] [PATCH] reject out of range memory in SetMemory APIs
by Ján Tomko
The APIs take the memory value in KiB and we store it in KiB
internally, but we cannot parse the whole ULONG_MAX range
on 64-bit systems, because virDomainParseScaledValue
needs to fit the value in bytes in an unsigned long long.
https://bugzilla.redhat.com/show_bug.cgi?id=1176739
---
src/conf/domain_conf.c | 7 +------
src/libvirt-domain.c | 18 ++++++++++++++++++
src/libvirt_private.syms | 1 +
src/util/virutil.c | 20 ++++++++++++++++++++
src/util/virutil.h | 1 +
5 files changed, 41 insertions(+), 6 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 4cd36a1..821a43c 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -7116,12 +7116,7 @@ virDomainParseMemory(const char *xpath,
int ret = -1;
unsigned long long bytes, max;
- /* On 32-bit machines, our bound is 0xffffffff * KiB. On 64-bit
- * machines, our bound is off_t (2^63). */
- if (capped && sizeof(unsigned long) < sizeof(long long))
- max = 1024ull * ULONG_MAX;
- else
- max = LLONG_MAX;
+ max = virMemoryMaxValue(capped);
ret = virDomainParseScaledValue(xpath, units_xpath, ctxt,
&bytes, 1024, max, required);
diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
index 7dcd40e..d467758 100644
--- a/src/libvirt-domain.c
+++ b/src/libvirt-domain.c
@@ -1850,6 +1850,12 @@ virDomainSetMaxMemory(virDomainPtr domain, unsigned long memory)
virCheckReadOnlyGoto(conn->flags, error);
virCheckNonZeroArgGoto(memory, error);
+ if (virMemoryMaxValue(true) / 1024 <= memory) {
+ virReportError(VIR_ERR_OVERFLOW, _("input too large: %lu"),
+ memory);
+ goto error;
+ }
+
if (conn->driver->domainSetMaxMemory) {
int ret;
ret = conn->driver->domainSetMaxMemory(domain, memory);
@@ -1896,6 +1902,12 @@ virDomainSetMemory(virDomainPtr domain, unsigned long memory)
virCheckReadOnlyGoto(conn->flags, error);
virCheckNonZeroArgGoto(memory, error);
+ if (virMemoryMaxValue(true) / 1024 <= memory) {
+ virReportError(VIR_ERR_OVERFLOW, _("input too large: %lu"),
+ memory);
+ goto error;
+ }
+
if (conn->driver->domainSetMemory) {
int ret;
ret = conn->driver->domainSetMemory(domain, memory);
@@ -1953,6 +1965,12 @@ virDomainSetMemoryFlags(virDomainPtr domain, unsigned long memory,
virCheckReadOnlyGoto(conn->flags, error);
virCheckNonZeroArgGoto(memory, error);
+ if (virMemoryMaxValue(true) / 1024 <= memory) {
+ virReportError(VIR_ERR_OVERFLOW, _("input too large: %lu"),
+ memory);
+ goto error;
+ }
+
if (conn->driver->domainSetMemoryFlags) {
int ret;
ret = conn->driver->domainSetMemoryFlags(domain, memory, flags);
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index c8e6fb4..e77ca81 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -2331,6 +2331,7 @@ virIsSUID;
virManageVport;
virMemoryLimitIsSet;
virMemoryLimitTruncate;
+virMemoryMaxValue;
virParseNumber;
virParseOwnershipIds;
virParseVersionString;
diff --git a/src/util/virutil.c b/src/util/virutil.c
index 0426517..e190308 100644
--- a/src/util/virutil.c
+++ b/src/util/virutil.c
@@ -2598,3 +2598,23 @@ virMemoryLimitIsSet(unsigned long long value)
{
return value < VIR_DOMAIN_MEMORY_PARAM_UNLIMITED;
}
+
+
+/**
+ * virMemoryMaxValue
+ *
+ * @ulong: whether the value must fit into unsigned long
+ * (unsigned long long is assumed otherwise)
+ *
+ * Returns the maximum possible memory value in bytes.
+ */
+unsigned long long
+virMemoryMaxValue(bool ulong)
+{
+ /* On 32-bit machines, our bound is 0xffffffff * KiB. On 64-bit
+ * machines, our bound is off_t (2^63). */
+ if (ulong && sizeof(unsigned long) < sizeof(long long))
+ return 1024ull * ULONG_MAX;
+ else
+ return LLONG_MAX;
+}
diff --git a/src/util/virutil.h b/src/util/virutil.h
index 55a3bd6..c78b357 100644
--- a/src/util/virutil.h
+++ b/src/util/virutil.h
@@ -245,5 +245,6 @@ long virGetSystemPageSizeKB(void);
unsigned long long virMemoryLimitTruncate(unsigned long long value);
bool virMemoryLimitIsSet(unsigned long long value);
+unsigned long long virMemoryMaxValue(bool ulong);
#endif /* __VIR_UTIL_H__ */
--
2.0.5
9 years, 6 months
[libvirt] [PATCH v2 0/4] Introduce pci-serial
by Michal Privoznik
diff to v1:
- Fix hot(un-)plug
Michal Privoznik (4):
Introduce pci-serial
qemu: Implement pci-serial
qemuDomainAttachChrDevice: Fix chardev hotplug
qemuDomainDetachChrDevice: Fix chardev hot-unplug
docs/formatdomain.html.in | 16 ++++++----
docs/schemas/domaincommon.rng | 1 +
src/conf/domain_conf.c | 3 +-
src/conf/domain_conf.h | 1 +
src/qemu/qemu_capabilities.c | 2 ++
src/qemu/qemu_capabilities.h | 1 +
src/qemu/qemu_command.c | 18 +++++++++++
src/qemu/qemu_hotplug.c | 36 ++++++++++++++++-----
tests/qemucapabilitiesdata/caps_1.3.1-1.caps | 1 +
tests/qemucapabilitiesdata/caps_1.4.2-1.caps | 1 +
tests/qemucapabilitiesdata/caps_1.5.3-1.caps | 1 +
tests/qemucapabilitiesdata/caps_1.6.0-1.caps | 1 +
tests/qemucapabilitiesdata/caps_1.6.50-1.caps | 1 +
tests/qemucapabilitiesdata/caps_2.1.1-1.caps | 1 +
.../qemuxml2argv-pci-serial-dev-chardev.args | 7 ++++
.../qemuxml2argv-pci-serial-dev-chardev.xml | 37 ++++++++++++++++++++++
tests/qemuxml2argvtest.c | 3 ++
tests/qemuxml2xmltest.c | 1 +
18 files changed, 117 insertions(+), 15 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pci-serial-dev-chardev.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pci-serial-dev-chardev.xml
--
2.3.6
9 years, 6 months
[libvirt] [PATCH v2] parallels: remove connection wide wait timeout
by Nikolay Shirokovskiy
We have a lot of passing arguments code just to pass connection
object cause it holds jobTimeout. Taking into account that
right now this value is defined at compile time let's just
get rid of it and make arguments list more clear in many
places.
In case we later need some runtime configurable timeout
value we can provide this value through arguments
function already operate such as a parallels domain
object etc as this timeouts are operation( and thus
object) specific in practice.
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy(a)parallels.com>
---
src/parallels/parallels_driver.c | 9 ++--
src/parallels/parallels_sdk.c | 108 +++++++++++++++++---------------------
src/parallels/parallels_sdk.h | 27 ++++-----
src/parallels/parallels_utils.h | 1 -
4 files changed, 64 insertions(+), 81 deletions(-)
diff --git a/src/parallels/parallels_driver.c b/src/parallels/parallels_driver.c
index 205ec1c..4b87213 100644
--- a/src/parallels/parallels_driver.c
+++ b/src/parallels/parallels_driver.c
@@ -214,7 +214,7 @@ parallelsOpenDefault(virConnectPtr conn)
goto err_free;
}
- if (prlsdkInit(privconn)) {
+ if (prlsdkInit()) {
VIR_DEBUG("%s", _("Can't initialize Parallels SDK"));
goto err_free;
}
@@ -1007,7 +1007,6 @@ parallelsDomainManagedSave(virDomainPtr domain, unsigned int flags)
static int
parallelsDomainManagedSaveRemove(virDomainPtr domain, unsigned int flags)
{
- parallelsConnPtr privconn = domain->conn->privateData;
virDomainObjPtr dom = NULL;
int state, reason;
int ret = -1;
@@ -1022,7 +1021,7 @@ parallelsDomainManagedSaveRemove(virDomainPtr domain, unsigned int flags)
if (!(state == VIR_DOMAIN_SHUTOFF && reason == VIR_DOMAIN_SHUTOFF_SAVED))
goto cleanup;
- ret = prlsdkDomainManagedSaveRemove(privconn, dom);
+ ret = prlsdkDomainManagedSaveRemove(dom);
cleanup:
virObjectUnlock(dom);
@@ -1071,7 +1070,7 @@ static int parallelsDomainAttachDeviceFlags(virDomainPtr dom, const char *xml,
switch (dev->type) {
case VIR_DOMAIN_DEVICE_DISK:
- ret = prlsdkAttachVolume(dom->conn, privdom, dev->data.disk);
+ ret = prlsdkAttachVolume(privdom, dev->data.disk);
if (ret) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("disk attach failed"));
@@ -1140,7 +1139,7 @@ static int parallelsDomainDetachDeviceFlags(virDomainPtr dom, const char *xml,
switch (dev->type) {
case VIR_DOMAIN_DEVICE_DISK:
- ret = prlsdkDetachVolume(dom->conn, privdom, dev->data.disk);
+ ret = prlsdkDetachVolume(privdom, dev->data.disk);
if (ret) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("disk detach failed"));
diff --git a/src/parallels/parallels_sdk.c b/src/parallels/parallels_sdk.c
index fcd274f..d48d4b7 100644
--- a/src/parallels/parallels_sdk.c
+++ b/src/parallels/parallels_sdk.c
@@ -35,8 +35,6 @@
#define VIR_FROM_THIS VIR_FROM_PARALLELS
#define JOB_INFINIT_WAIT_TIMEOUT UINT_MAX
-PRL_UINT32 defaultJobTimeout = JOB_INFINIT_WAIT_TIMEOUT;
-
VIR_LOG_INIT("parallels.sdk");
/*
@@ -179,9 +177,9 @@ getJobResultHelper(PRL_HANDLE job, unsigned int timeout, PRL_HANDLE *result,
return ret;
}
-#define getJobResult(job, timeout, result) \
- getJobResultHelper(job, timeout, result, __FILE__, \
- __FUNCTION__, __LINE__)
+#define getJobResult(job, result) \
+ getJobResultHelper(job, JOB_INFINIT_WAIT_TIMEOUT, \
+ result, __FILE__, __FUNCTION__, __LINE__)
static PRL_RESULT
waitJobHelper(PRL_HANDLE job, unsigned int timeout,
@@ -197,12 +195,13 @@ waitJobHelper(PRL_HANDLE job, unsigned int timeout,
return ret;
}
-#define waitJob(job, timeout) \
- waitJobHelper(job, timeout, __FILE__, \
+#define waitJob(job) \
+ waitJobHelper(job, JOB_INFINIT_WAIT_TIMEOUT, __FILE__, \
__FUNCTION__, __LINE__)
+
int
-prlsdkInit(parallelsConnPtr privconn)
+prlsdkInit(void)
{
PRL_RESULT ret;
@@ -212,8 +211,6 @@ prlsdkInit(parallelsConnPtr privconn)
return -1;
}
- privconn->jobTimeout = JOB_INFINIT_WAIT_TIMEOUT;
-
return 0;
};
@@ -238,7 +235,7 @@ prlsdkConnect(parallelsConnPtr privconn)
job = PrlSrv_LoginLocalEx(privconn->server, NULL, 0,
PSL_HIGH_SECURITY, PACF_NON_INTERACTIVE_MODE);
- if (waitJob(job, privconn->jobTimeout)) {
+ if (waitJob(job)) {
PrlHandle_Free(privconn->server);
return -1;
}
@@ -252,7 +249,7 @@ prlsdkDisconnect(parallelsConnPtr privconn)
PRL_HANDLE job;
job = PrlSrv_Logoff(privconn->server);
- waitJob(job, privconn->jobTimeout);
+ waitJob(job);
PrlHandle_Free(privconn->server);
}
@@ -269,7 +266,7 @@ prlsdkSdkDomainLookup(parallelsConnPtr privconn,
int ret = -1;
job = PrlSrv_GetVmConfig(privconn->server, id, flags);
- if (PRL_FAILED(getJobResult(job, privconn->jobTimeout, &result)))
+ if (PRL_FAILED(getJobResult(job, &result)))
goto cleanup;
pret = PrlResult_GetParamByIndex(result, 0, sdkdom);
@@ -374,9 +371,7 @@ prlsdkGetDomainIds(PRL_HANDLE sdkdom,
}
static int
-prlsdkGetDomainState(parallelsConnPtr privconn,
- PRL_HANDLE sdkdom,
- VIRTUAL_MACHINE_STATE_PTR vmState)
+prlsdkGetDomainState(PRL_HANDLE sdkdom, VIRTUAL_MACHINE_STATE_PTR vmState)
{
PRL_HANDLE job = PRL_INVALID_HANDLE;
PRL_HANDLE result = PRL_INVALID_HANDLE;
@@ -386,7 +381,7 @@ prlsdkGetDomainState(parallelsConnPtr privconn,
job = PrlVm_GetState(sdkdom);
- if (PRL_FAILED(getJobResult(job, privconn->jobTimeout, &result)))
+ if (PRL_FAILED(getJobResult(job, &result)))
goto cleanup;
pret = PrlResult_GetParamByIndex(result, 0, &vmInfo);
@@ -1354,7 +1349,7 @@ prlsdkLoadDomain(parallelsConnPtr privconn,
dom->privateDataFreeFunc = prlsdkDomObjFreePrivate;
dom->persistent = 1;
- if (prlsdkGetDomainState(privconn, sdkdom, &domainState) < 0)
+ if (prlsdkGetDomainState(sdkdom, &domainState) < 0)
goto error;
if (prlsdkConvertDomainState(domainState, envId, dom) < 0)
@@ -1404,7 +1399,7 @@ prlsdkLoadDomains(parallelsConnPtr privconn)
job = PrlSrv_GetVmListEx(privconn->server, PVTF_VM | PVTF_CT);
- if (PRL_FAILED(getJobResult(job, privconn->jobTimeout, &result)))
+ if (PRL_FAILED(getJobResult(job, &result)))
return -1;
pret = PrlResult_GetParamsCount(result, ¶msCount);
@@ -1464,7 +1459,7 @@ prlsdkUpdateDomain(parallelsConnPtr privconn, virDomainObjPtr dom)
parallelsDomObjPtr pdom = dom->privateData;
job = PrlVm_RefreshConfig(pdom->sdkdom);
- if (waitJob(job, privconn->jobTimeout))
+ if (waitJob(job))
return -1;
retdom = prlsdkLoadDomain(privconn, pdom->sdkdom, dom);
@@ -1748,56 +1743,54 @@ void prlsdkUnsubscribeFromPCSEvents(parallelsConnPtr privconn)
logPrlError(ret);
}
-PRL_RESULT prlsdkStart(parallelsConnPtr privconn, PRL_HANDLE sdkdom)
+PRL_RESULT prlsdkStart(PRL_HANDLE sdkdom)
{
PRL_HANDLE job = PRL_INVALID_HANDLE;
job = PrlVm_StartEx(sdkdom, PSM_VM_START, 0);
- return PRL_FAILED(waitJob(job, privconn->jobTimeout)) ? -1 : 0;
+ return waitJob(job);
}
-static PRL_RESULT prlsdkStopEx(parallelsConnPtr privconn,
- PRL_HANDLE sdkdom,
- PRL_UINT32 mode)
+static PRL_RESULT prlsdkStopEx(PRL_HANDLE sdkdom, PRL_UINT32 mode)
{
PRL_HANDLE job = PRL_INVALID_HANDLE;
job = PrlVm_StopEx(sdkdom, mode, 0);
- return waitJob(job, privconn->jobTimeout);
+ return waitJob(job);
}
-PRL_RESULT prlsdkKill(parallelsConnPtr privconn, PRL_HANDLE sdkdom)
+PRL_RESULT prlsdkKill(PRL_HANDLE sdkdom)
{
- return prlsdkStopEx(privconn, sdkdom, PSM_KILL);
+ return prlsdkStopEx(sdkdom, PSM_KILL);
}
-PRL_RESULT prlsdkStop(parallelsConnPtr privconn, PRL_HANDLE sdkdom)
+PRL_RESULT prlsdkStop(PRL_HANDLE sdkdom)
{
- return prlsdkStopEx(privconn, sdkdom, PSM_SHUTDOWN);
+ return prlsdkStopEx(sdkdom, PSM_SHUTDOWN);
}
-PRL_RESULT prlsdkPause(parallelsConnPtr privconn, PRL_HANDLE sdkdom)
+PRL_RESULT prlsdkPause(PRL_HANDLE sdkdom)
{
PRL_HANDLE job = PRL_INVALID_HANDLE;
job = PrlVm_Pause(sdkdom, false);
- return waitJob(job, privconn->jobTimeout);
+ return waitJob(job);
}
-PRL_RESULT prlsdkResume(parallelsConnPtr privconn, PRL_HANDLE sdkdom)
+PRL_RESULT prlsdkResume(PRL_HANDLE sdkdom)
{
PRL_HANDLE job = PRL_INVALID_HANDLE;
job = PrlVm_Resume(sdkdom);
- return waitJob(job, privconn->jobTimeout);
+ return waitJob(job);
}
-PRL_RESULT prlsdkSuspend(parallelsConnPtr privconn, PRL_HANDLE sdkdom)
+PRL_RESULT prlsdkSuspend(PRL_HANDLE sdkdom)
{
PRL_HANDLE job = PRL_INVALID_HANDLE;
job = PrlVm_Suspend(sdkdom);
- return waitJob(job, privconn->jobTimeout);
+ return waitJob(job);
}
int
@@ -1810,7 +1803,7 @@ prlsdkDomainChangeStateLocked(parallelsConnPtr privconn,
virErrorNumber virerr;
pdom = dom->privateData;
- pret = chstate(privconn, pdom->sdkdom);
+ pret = chstate(pdom->sdkdom);
if (PRL_FAILED(pret)) {
virResetLastError();
@@ -2805,7 +2798,7 @@ static int prlsdkAddNet(PRL_HANDLE sdkdom,
prlsdkCheckRetGoto(pret, cleanup);
job = PrlSrv_AddVirtualNetwork(privconn->server, vnet, 0);
- if (PRL_FAILED(pret = waitJob(job, privconn->jobTimeout)))
+ if (PRL_FAILED(pret = waitJob(job)))
goto cleanup;
pret = PrlVmDev_SetEmulatedType(sdknet, PNA_BRIDGED_ETHERNET);
@@ -2844,7 +2837,7 @@ static void prlsdkDelNet(parallelsConnPtr privconn, virDomainNetDefPtr net)
prlsdkCheckRetGoto(pret, cleanup);
PrlSrv_DeleteVirtualNetwork(privconn->server, vnet, 0);
- if (PRL_FAILED(pret = waitJob(job, privconn->jobTimeout)))
+ if (PRL_FAILED(pret = waitJob(job)))
goto cleanup;
cleanup:
@@ -3041,23 +3034,20 @@ static int prlsdkAddDisk(PRL_HANDLE sdkdom, virDomainDiskDefPtr disk, bool bootD
}
int
-prlsdkAttachVolume(virConnectPtr conn,
- virDomainObjPtr dom,
- virDomainDiskDefPtr disk)
+prlsdkAttachVolume(virDomainObjPtr dom, virDomainDiskDefPtr disk)
{
int ret = -1;
- parallelsConnPtr privconn = conn->privateData;
parallelsDomObjPtr privdom = dom->privateData;
PRL_HANDLE job = PRL_INVALID_HANDLE;
job = PrlVm_BeginEdit(privdom->sdkdom);
- if (PRL_FAILED(waitJob(job, privconn->jobTimeout)))
+ if (PRL_FAILED(waitJob(job)))
goto cleanup;
ret = prlsdkAddDisk(privdom->sdkdom, disk, false);
if (ret == 0) {
job = PrlVm_CommitEx(privdom->sdkdom, PVCF_DETACH_HDD_BUNDLE);
- if (PRL_FAILED(waitJob(job, privconn->jobTimeout))) {
+ if (PRL_FAILED(waitJob(job))) {
ret = -1;
goto cleanup;
}
@@ -3113,12 +3103,10 @@ prlsdkGetDiskIndex(PRL_HANDLE sdkdom, virDomainDiskDefPtr disk)
return idx;
}
-int prlsdkDetachVolume(virConnectPtr conn,
- virDomainObjPtr dom,
- virDomainDiskDefPtr disk)
+int
+prlsdkDetachVolume(virDomainObjPtr dom, virDomainDiskDefPtr disk)
{
int ret = -1, idx;
- parallelsConnPtr privconn = conn->privateData;
parallelsDomObjPtr privdom = dom->privateData;
PRL_HANDLE job = PRL_INVALID_HANDLE;
@@ -3127,13 +3115,13 @@ int prlsdkDetachVolume(virConnectPtr conn,
goto cleanup;
job = PrlVm_BeginEdit(privdom->sdkdom);
- if (PRL_FAILED(waitJob(job, privconn->jobTimeout)))
+ if (PRL_FAILED(waitJob(job)))
goto cleanup;
ret = prlsdkDelDisk(privdom->sdkdom, idx);
if (ret == 0) {
job = PrlVm_CommitEx(privdom->sdkdom, PVCF_DETACH_HDD_BUNDLE);
- if (PRL_FAILED(waitJob(job, privconn->jobTimeout))) {
+ if (PRL_FAILED(waitJob(job))) {
ret = -1;
goto cleanup;
}
@@ -3314,14 +3302,14 @@ prlsdkApplyConfig(virConnectPtr conn,
return -1;
job = PrlVm_BeginEdit(sdkdom);
- if (PRL_FAILED(waitJob(job, privconn->jobTimeout)))
+ if (PRL_FAILED(waitJob(job)))
return -1;
ret = prlsdkDoApplyConfig(conn, sdkdom, new, dom->def);
if (ret == 0) {
job = PrlVm_CommitEx(sdkdom, PVCF_DETACH_HDD_BUNDLE);
- if (PRL_FAILED(waitJob(job, privconn->jobTimeout)))
+ if (PRL_FAILED(waitJob(job)))
ret = -1;
}
@@ -3345,7 +3333,7 @@ prlsdkCreateVm(virConnectPtr conn, virDomainDefPtr def)
prlsdkCheckRetGoto(pret, cleanup);
job = PrlSrv_GetSrvConfig(privconn->server);
- if (PRL_FAILED(getJobResult(job, privconn->jobTimeout, &result)))
+ if (PRL_FAILED(getJobResult(job, &result)))
goto cleanup;
pret = PrlResult_GetParamByIndex(result, 0, &srvconf);
@@ -3362,7 +3350,7 @@ prlsdkCreateVm(virConnectPtr conn, virDomainDefPtr def)
goto cleanup;
job = PrlVm_Reg(sdkdom, "", 1);
- if (PRL_FAILED(waitJob(job, privconn->jobTimeout)))
+ if (PRL_FAILED(waitJob(job)))
ret = -1;
cleanup:
@@ -3407,7 +3395,7 @@ prlsdkCreateCt(virConnectPtr conn, virDomainDefPtr def)
confParam.nOsVersion = 0;
job = PrlSrv_GetDefaultVmConfig(privconn->server, &confParam, 0);
- if (PRL_FAILED(getJobResult(job, privconn->jobTimeout, &result)))
+ if (PRL_FAILED(getJobResult(job, &result)))
goto cleanup;
pret = PrlResult_GetParamByIndex(result, 0, &sdkdom);
@@ -3425,7 +3413,7 @@ prlsdkCreateCt(virConnectPtr conn, virDomainDefPtr def)
job = PrlVm_RegEx(sdkdom, "",
PACF_NON_INTERACTIVE_MODE | PRNVM_PRESERVE_DISK);
- if (PRL_FAILED(waitJob(job, privconn->jobTimeout)))
+ if (PRL_FAILED(waitJob(job)))
ret = -1;
cleanup:
@@ -3444,7 +3432,7 @@ prlsdkUnregisterDomain(parallelsConnPtr privconn, virDomainObjPtr dom)
prlsdkDelNet(privconn, dom->def->nets[i]);
job = PrlVm_Unreg(privdom->sdkdom);
- if (PRL_FAILED(waitJob(job, privconn->jobTimeout)))
+ if (PRL_FAILED(waitJob(job)))
return -1;
if (prlsdkSendEvent(privconn, dom, VIR_DOMAIN_EVENT_UNDEFINED,
@@ -3456,13 +3444,13 @@ prlsdkUnregisterDomain(parallelsConnPtr privconn, virDomainObjPtr dom)
}
int
-prlsdkDomainManagedSaveRemove(parallelsConnPtr privconn, virDomainObjPtr dom)
+prlsdkDomainManagedSaveRemove(virDomainObjPtr dom)
{
parallelsDomObjPtr privdom = dom->privateData;
PRL_HANDLE job;
job = PrlVm_DropSuspendedState(privdom->sdkdom);
- if (PRL_FAILED(waitJob(job, privconn->jobTimeout)))
+ if (PRL_FAILED(waitJob(job)))
return -1;
return 0;
diff --git a/src/parallels/parallels_sdk.h b/src/parallels/parallels_sdk.h
index 3ad46c3..3f17fc8 100644
--- a/src/parallels/parallels_sdk.h
+++ b/src/parallels/parallels_sdk.h
@@ -24,7 +24,7 @@
#include "parallels_utils.h"
-int prlsdkInit(parallelsConnPtr privconn);
+int prlsdkInit(void);
void prlsdkDeinit(void);
int prlsdkConnect(parallelsConnPtr privconn);
void prlsdkDisconnect(parallelsConnPtr privconn);
@@ -35,14 +35,14 @@ prlsdkAddDomain(parallelsConnPtr privconn, const unsigned char *uuid);
int prlsdkUpdateDomain(parallelsConnPtr privconn, virDomainObjPtr dom);
int prlsdkSubscribeToPCSEvents(parallelsConnPtr privconn);
void prlsdkUnsubscribeFromPCSEvents(parallelsConnPtr privconn);
-PRL_RESULT prlsdkStart(parallelsConnPtr privconn, PRL_HANDLE sdkdom);
-PRL_RESULT prlsdkKill(parallelsConnPtr privconn, PRL_HANDLE sdkdom);
-PRL_RESULT prlsdkStop(parallelsConnPtr privconn, PRL_HANDLE sdkdom);
-PRL_RESULT prlsdkPause(parallelsConnPtr privconn, PRL_HANDLE sdkdom);
-PRL_RESULT prlsdkResume(parallelsConnPtr privconn, PRL_HANDLE sdkdom);
-PRL_RESULT prlsdkSuspend(parallelsConnPtr privconn, PRL_HANDLE sdkdom);
+PRL_RESULT prlsdkStart(PRL_HANDLE sdkdom);
+PRL_RESULT prlsdkKill(PRL_HANDLE sdkdom);
+PRL_RESULT prlsdkStop(PRL_HANDLE sdkdom);
+PRL_RESULT prlsdkPause(PRL_HANDLE sdkdom);
+PRL_RESULT prlsdkResume(PRL_HANDLE sdkdom);
+PRL_RESULT prlsdkSuspend(PRL_HANDLE sdkdom);
-typedef PRL_RESULT (*prlsdkChangeStateFunc)(parallelsConnPtr privconn, PRL_HANDLE sdkdom);
+typedef PRL_RESULT (*prlsdkChangeStateFunc)(PRL_HANDLE sdkdom);
int
prlsdkDomainChangeState(virDomainPtr domain,
prlsdkChangeStateFunc chstate);
@@ -59,11 +59,8 @@ int prlsdkCreateCt(virConnectPtr conn, virDomainDefPtr def);
int
prlsdkUnregisterDomain(parallelsConnPtr privconn, virDomainObjPtr dom);
int
-prlsdkDomainManagedSaveRemove(parallelsConnPtr privconn, virDomainObjPtr dom);
+prlsdkDomainManagedSaveRemove(virDomainObjPtr dom);
int
-prlsdkAttachVolume(virConnectPtr conn,
- virDomainObjPtr dom,
- virDomainDiskDefPtr disk);
-int prlsdkDetachVolume(virConnectPtr conn,
- virDomainObjPtr dom,
- virDomainDiskDefPtr disk);
+prlsdkAttachVolume(virDomainObjPtr dom, virDomainDiskDefPtr disk);
+int
+prlsdkDetachVolume(virDomainObjPtr dom, virDomainDiskDefPtr disk);
diff --git a/src/parallels/parallels_utils.h b/src/parallels/parallels_utils.h
index 3f49cec..2d1d405 100644
--- a/src/parallels/parallels_utils.h
+++ b/src/parallels/parallels_utils.h
@@ -62,7 +62,6 @@ struct _parallelsConn {
virDomainObjListPtr domains;
PRL_HANDLE server;
- PRL_UINT32 jobTimeout;
virStoragePoolObjList pools;
virNetworkObjListPtr networks;
virCapsPtr caps;
--
1.7.1
9 years, 6 months
[libvirt] [PATCHv2] Ignore bridge template names with multiple printf conversions
by Ján Tomko
For some reason, we allow a bridge name with %d in it, which we replace
with an unsigned integer to form a bridge name that does not yet exist
on the host.
Do not blindly pass it to virAsprintf if it's not the only conversion,
to prevent crashing on input like:
<network>
<name>test</name>
<forward mode='none'/>
<bridge name='virbr%d%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s'/>
</network>
Ignore any template strings that do not have exactly one %d conversion,
like we do in various drivers before calling virNetDevTapCreateInBridgePort.
---
v2: drop the unnecessary changes in networkBridgeNameValidate
src/network/bridge_driver.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index 3b879cd..fe2448d 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -2775,7 +2775,13 @@ networkFindUnusedBridgeName(virNetworkObjListPtr nets,
int ret = -1, id = 0;
char *newname = NULL;
- const char *templ = def->bridge ? def->bridge : "virbr%d";
+ const char *templ = "virbr%d";
+ const char *p;
+
+ if (def->bridge &&
+ (p = strchr(def->bridge, '%')) == strrchr(def->bridge, '%') &&
+ strstr(def->bridge, "%d"))
+ templ = def->bridge;
do {
if (virAsprintf(&newname, templ, id) < 0)
--
2.0.5
9 years, 6 months
[libvirt] [PATCH] qemu: clear useless code
by zhang bo
The variable 'now' is useless in qemuMigrationPrepareAny(), so I clear it.
Signed-off-by: Wang Yufei <james.wangyufei(a)huawei.com>
Signed-off-by: Zhang Bo <oscar.zhangbo(a)huawei.com>
---
src/qemu/qemu_migration.c | 4 ----
1 file changed, 4 deletions(-)
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index c1af704..4dcba7a 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -2913,7 +2913,6 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver,
int ret = -1;
int dataFD[2] = { -1, -1 };
qemuDomainObjPrivatePtr priv = NULL;
- unsigned long long now;
qemuMigrationCookiePtr mig = NULL;
bool tunnel = !!st;
char *xmlout = NULL;
@@ -2923,9 +2922,6 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver,
bool abort_on_error = !!(flags & VIR_MIGRATE_ABORT_ON_ERROR);
bool taint_hook = false;
- if (virTimeMillisNow(&now) < 0)
- return -1;
-
virNWFilterReadLockFilterUpdates();
if (flags & VIR_MIGRATE_OFFLINE) {
--
1.7.12.4
9 years, 6 months
[libvirt] [PATCH] Ignore Vim swap files.
by Andrea Bolognani
This removes some noise when you're working on the repository
and also have a bunch of source files open in Vim in another
terminal.
---
.gitignore | 1 +
1 file changed, 1 insertion(+)
diff --git a/.gitignore b/.gitignore
index 7bcf359..1a5cf8e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -18,6 +18,7 @@
*.pyc
*.rej
*.s
+*.swp
*~
.#*
.deps
--
2.1.0
9 years, 6 months