[libvirt] [PATCH] Fix build --without-network
by Martin Kletzander
In order not to bring in any link dependencies, bridge driver doesn't
use the usual stubs as other conditionally-built code does. However,
having the function as a macro imposes a problem with possibly unused
variables if just defined as "0". This was worked around by using
(dom=dom, iface=iface, 0) which should act like a 0 if used in a
condition. However, gcc still bugs about that, so I came up with
another way how to fix that.
Using static inline functions in the header won't collide with anything,
it fixes the bug and does one thing that the macro didn't do. It checks
whenther passed variables are pointers of compatible type. It has only
one downside, and that is that we need to either a) define it with
ATTRIBUTE_UNUSED, which needs an exception in cfg.mk or b) do something
like ignore_value(variable); in the function body. I went with the
first variant.
Signed-off-by: Martin Kletzander <mkletzan(a)redhat.com>
---
Notes:
I can go with the version (b) if that's the preferred one.
cfg.mk | 4 ++--
src/network/bridge_driver.h | 19 ++++++++++++++++---
2 files changed, 18 insertions(+), 5 deletions(-)
diff --git a/cfg.mk b/cfg.mk
index 9ba2134..796ed80 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -1,5 +1,5 @@
# Customize Makefile.maint. -*- makefile -*-
-# Copyright (C) 2008-2014 Red Hat, Inc.
+# Copyright (C) 2008-2015 Red Hat, Inc.
# Copyright (C) 2003-2008 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
@@ -1184,7 +1184,7 @@ exclude_file_name_regexp--sc_prohibit_getenv = \
^tests/.*\.[ch]$$
exclude_file_name_regexp--sc_avoid_attribute_unused_in_header = \
- ^src/util/virlog\.h$$
+ ^(src/util/virlog\.h|src/network/bridge_driver\.h)$$
exclude_file_name_regexp--sc_prohibit_mixed_case_abbreviations = \
^src/(vbox/vbox_CAPI.*.h|esx/esx_vi.(c|h)|esx/esx_storage_backend_iscsi.c)$$
diff --git a/src/network/bridge_driver.h b/src/network/bridge_driver.h
index 2f801ee..513ccf7 100644
--- a/src/network/bridge_driver.h
+++ b/src/network/bridge_driver.h
@@ -1,7 +1,7 @@
/*
* bridge_driver.h: core driver methods for managing networks
*
- * Copyright (C) 2006-2013 Red Hat, Inc.
+ * Copyright (C) 2006-2015 Red Hat, Inc.
* Copyright (C) 2006 Daniel P. Berrange
*
* This library is free software; you can redistribute it and/or
@@ -55,11 +55,24 @@ int networkDnsmasqConfContents(virNetworkObjPtr network,
# else
/* Define no-op replacements that don't drag in any link dependencies. */
# define networkAllocateActualDevice(dom, iface) 0
-# define networkNotifyActualDevice(dom, iface) (dom=dom, iface=iface, 0)
-# define networkReleaseActualDevice(dom, iface) (dom=dom, iface=iface, 0)
# define networkGetNetworkAddress(netname, netaddr) (-2)
# define networkDnsmasqConfContents(network, pidfile, configstr, \
dctx, caps) 0
+
+static inline int
+networkNotifyActualDevice(virDomainDefPtr dom ATTRIBUTE_UNUSED,
+ virDomainNetDefPtr iface ATTRIBUTE_UNUSED)
+{
+ return 0;
+}
+
+static inline int
+networkReleaseActualDevice(virDomainDefPtr dom ATTRIBUTE_UNUSED,
+ virDomainNetDefPtr iface ATTRIBUTE_UNUSED)
+{
+ return 0;
+}
+
# endif
typedef char *(*networkDnsmasqLeaseFileNameFunc)(const char *netname);
--
2.3.6
9 years, 7 months
[libvirt] [PATCH] 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 | 6 +-
src/parallels/parallels_sdk.c | 98 +++++++++++++++++---------------------
src/parallels/parallels_sdk.h | 22 ++++-----
src/parallels/parallels_utils.h | 1 -
4 files changed, 57 insertions(+), 70 deletions(-)
diff --git a/src/parallels/parallels_driver.c b/src/parallels/parallels_driver.c
index 3aa87ca..63bf638 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;
}
@@ -1087,7 +1087,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);
@@ -1139,7 +1139,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"));
diff --git a/src/parallels/parallels_sdk.c b/src/parallels/parallels_sdk.c
index e1ba7cf..83de1de 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);
@@ -1356,7 +1351,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)
@@ -1406,7 +1401,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);
@@ -1466,7 +1461,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);
@@ -1750,56 +1745,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
@@ -1812,7 +1805,7 @@ prlsdkDomainChangeStateLocked(parallelsConnPtr privconn,
virErrorNumber virerr;
pdom = dom->privateData;
- pret = chstate(privconn, pdom->sdkdom);
+ pret = chstate(pdom->sdkdom);
if (PRL_FAILED(pret)) {
virResetLastError();
@@ -2803,7 +2796,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);
@@ -2842,7 +2835,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:
@@ -3020,23 +3013,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;
}
@@ -3217,14 +3207,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;
}
@@ -3248,7 +3238,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);
@@ -3265,7 +3255,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:
@@ -3310,7 +3300,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);
@@ -3328,7 +3318,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:
@@ -3347,7 +3337,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,
@@ -3359,13 +3349,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 00fa44d..027dd0c 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,8 +59,6 @@ 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);
+prlsdkAttachVolume(virDomainObjPtr dom, virDomainDiskDefPtr disk);
diff --git a/src/parallels/parallels_utils.h b/src/parallels/parallels_utils.h
index 0f29374..912f450 100644
--- a/src/parallels/parallels_utils.h
+++ b/src/parallels/parallels_utils.h
@@ -59,7 +59,6 @@ struct _parallelsConn {
virMutex lock;
virDomainObjListPtr domains;
PRL_HANDLE server;
- PRL_UINT32 jobTimeout;
virStoragePoolObjList pools;
virNetworkObjListPtr networks;
virCapsPtr caps;
--
1.7.1
9 years, 7 months
[libvirt] [PATCH] qemu: vnc: error out for invalid port number
by Pavel Hrdina
In the XML we have the vnc port number, but QEMU takes on command line
a vnc screen number, it's port-5900. We should fail with error message
that only ports in range [5900,65535] are valid.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1164966
Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
---
src/qemu/qemu_command.c | 96 +++++++++++++++++++++++++++----------------------
1 file changed, 53 insertions(+), 43 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 8ccbe82..5d0a167 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -7591,50 +7591,60 @@ qemuBuildGraphicsVNCCommandLine(virQEMUDriverConfigPtr cfg,
virBufferAsprintf(&opt, "unix:%s", graphics->data.vnc.socket);
- } else if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VNC_COLON)) {
- switch (virDomainGraphicsListenGetType(graphics, 0)) {
- case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS:
- listenAddr = virDomainGraphicsListenGetAddress(graphics, 0);
- break;
-
- case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK:
- listenNetwork = virDomainGraphicsListenGetNetwork(graphics, 0);
- if (!listenNetwork)
- break;
- ret = networkGetNetworkAddress(listenNetwork, &netAddr);
- if (ret <= -2) {
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- "%s", _("network-based listen not possible, "
- "network driver not present"));
- goto error;
- }
- if (ret < 0)
- goto error;
-
- listenAddr = netAddr;
- /* store the address we found in the <graphics> element so it will
- * show up in status. */
- if (virDomainGraphicsListenSetAddress(graphics, 0,
- listenAddr, -1, false) < 0)
- goto error;
- break;
- }
-
- if (!listenAddr)
- listenAddr = cfg->vncListen;
-
- escapeAddr = strchr(listenAddr, ':') != NULL;
- if (escapeAddr)
- virBufferAsprintf(&opt, "[%s]", listenAddr);
- else
- virBufferAdd(&opt, listenAddr, -1);
- virBufferAsprintf(&opt, ":%d",
- graphics->data.vnc.port - 5900);
-
- VIR_FREE(netAddr);
} else {
- virBufferAsprintf(&opt, "%d",
- graphics->data.vnc.port - 5900);
+ if (!graphics->data.vnc.autoport &&
+ (graphics->data.vnc.port < 5900 ||
+ graphics->data.vnc.port > 65535)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("vnc port must be in range [5900,65535]"));
+ goto error;
+ }
+
+ if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VNC_COLON)) {
+ switch (virDomainGraphicsListenGetType(graphics, 0)) {
+ case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS:
+ listenAddr = virDomainGraphicsListenGetAddress(graphics, 0);
+ break;
+
+ case VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK:
+ listenNetwork = virDomainGraphicsListenGetNetwork(graphics, 0);
+ if (!listenNetwork)
+ break;
+ ret = networkGetNetworkAddress(listenNetwork, &netAddr);
+ if (ret <= -2) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ "%s", _("network-based listen not possible, "
+ "network driver not present"));
+ goto error;
+ }
+ if (ret < 0)
+ goto error;
+
+ listenAddr = netAddr;
+ /* store the address we found in the <graphics> element so it
+ * will show up in status. */
+ if (virDomainGraphicsListenSetAddress(graphics, 0,
+ listenAddr, -1, false) < 0)
+ goto error;
+ break;
+ }
+
+ if (!listenAddr)
+ listenAddr = cfg->vncListen;
+
+ escapeAddr = strchr(listenAddr, ':') != NULL;
+ if (escapeAddr)
+ virBufferAsprintf(&opt, "[%s]", listenAddr);
+ else
+ virBufferAdd(&opt, listenAddr, -1);
+ virBufferAsprintf(&opt, ":%d",
+ graphics->data.vnc.port - 5900);
+
+ VIR_FREE(netAddr);
+ } else {
+ virBufferAsprintf(&opt, "%d",
+ graphics->data.vnc.port - 5900);
+ }
}
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VNC_COLON)) {
--
2.3.6
9 years, 7 months
[libvirt] time: event poll may become un-triggerable after changing system clock.
by zhang bo
event poll may become un-triggerable after changing system clock.
The steps to reproduce the problem:
1 run event-test
1 define and start a domain with name vm1.
2 destroy vm1
3 change system time to 1 hour before when timer.expiresAt has been set in virEventPollUpdateTimeout
(and before virEventPollDispatchTimeouts()).
4 event-test will recive no message until 1 hour later.
The reasons for the problem is :
1 The value of timer.expiresAt is set by virTimeMillisNowRaw. virTimeMillisNowRaw is effectable by settimeofday(),
bacause it uses CLOCK_REALTIME to get time.
2 If we change the system time to a time long before now, after that timer.expiresAt has been set. timer.expiresAt
is not affected, while virEventPollDispatchTimeouts is.
Suppose it's now May 12th, and we set it to 10th, then the expiresAt is 12th, and the time virEventPollDispatchTimeouts
got is 10th.
if (eventLoop.timeouts[i].expiresAt <= (now+20)) { // expiresAt will not be less than now until 2 days later.
*Solution(not good enough)*:
1 change the clock mode in virTimeMillisNowRaw from REALTIME to MONOTONIC, which would not be affected by
settimeofday().
2 add the time got from clock_gettime(*MONOTONIC*) with the system-start-time from epoch, making it equal to the value got from REALTIME.
3 As that the timestamp of the log message should follow system time, so we keep it to REALTIME as before.
However, there's still problems:
1 pthread_cond_wait() gets time with REALTIME mode. When we change system time, pthread_cond_wait() may still be affected.
So, Is there any other better solution? thanks in advance.
oscar
9 years, 7 months
[libvirt] [PATCH 0/2] Couple of sysinfo fixes
by Michal Privoznik
I've just tried sysinfo on my RPi, and found some bugs there.
Michal Privoznik (2):
virSysinfoParseProcessor: Drop useless check for NULL
sysinfo: Fix reports on arm
src/util/virsysinfo.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
--
2.3.6
9 years, 7 months
[libvirt] [PATCH] libxl: Disallow save or migrate when host devices are assigned to a guest.
by Konrad Rzeszutek Wilk
It is unhealthy. If the device is not doing any DMA operations
it would work - but if you are saving and there are DMA operations
happening the chance of corruption (outstanding DMAs) increase.
As such re-use the check migration used.
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk(a)oracle.com>
---
src/libxl/libxl_domain.c | 19 +++++++++++++++++++
src/libxl/libxl_domain.h | 3 +++
src/libxl/libxl_driver.c | 6 ++++++
src/libxl/libxl_migration.c | 15 +--------------
4 files changed, 29 insertions(+), 14 deletions(-)
diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c
index 5e0ab56..c038989 100644
--- a/src/libxl/libxl_domain.c
+++ b/src/libxl/libxl_domain.c
@@ -178,6 +178,25 @@ libxlDomainObjEndJob(libxlDriverPrivatePtr driver ATTRIBUTE_UNUSED,
return virObjectUnref(obj);
}
+/*
+ * Checks whether the domain has host devices (PCIe) to disallow
+ * migration or saving of guest - unless they are detached.
+ *
+ * Returns true if the domain has host devices, otherwise false.
+ */
+bool
+libxlDomainHasHostDevices(virDomainDefPtr def)
+{
+ /* Migration is not allowed if definition contains any hostdevs */
+ if (def->nhostdevs > 0) {
+ virReportError(VIR_ERR_OPERATION_INVALID, "%s",
+ _("domain has assigned host devices"));
+ return true;
+ }
+
+ return false;
+}
+
static void *
libxlDomainObjPrivateAlloc(void)
{
diff --git a/src/libxl/libxl_domain.h b/src/libxl/libxl_domain.h
index aa647b8..76c0c8d 100644
--- a/src/libxl/libxl_domain.h
+++ b/src/libxl/libxl_domain.h
@@ -95,6 +95,9 @@ char *
libxlDomainManagedSavePath(libxlDriverPrivatePtr driver,
virDomainObjPtr vm);
+bool
+libxlDomainHasHostDevices(virDomainDefPtr def);
+
int
libxlDomainSaveImageOpen(libxlDriverPrivatePtr driver,
libxlDriverConfigPtr cfg,
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 9eb071e..b9faba8 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -1650,6 +1650,9 @@ libxlDomainSaveFlags(virDomainPtr dom, const char *to, const char *dxml,
goto endjob;
}
+ if (libxlDomainHasHostDevices(vm->def))
+ goto endjob;
+
if (libxlDoDomainSave(driver, vm, to) < 0)
goto endjob;
@@ -1876,6 +1879,9 @@ libxlDomainManagedSave(virDomainPtr dom, unsigned int flags)
goto endjob;
}
+ if (libxlDomainHasHostDevices(vm->def))
+ goto endjob;
+
name = libxlDomainManagedSavePath(driver, vm);
if (name == NULL)
goto endjob;
diff --git a/src/libxl/libxl_migration.c b/src/libxl/libxl_migration.c
index 4010506..aaed448c 100644
--- a/src/libxl/libxl_migration.c
+++ b/src/libxl/libxl_migration.c
@@ -209,19 +209,6 @@ libxlDoMigrateSend(libxlDriverPrivatePtr driver,
return ret;
}
-static bool
-libxlDomainMigrationIsAllowed(virDomainDefPtr def)
-{
- /* Migration is not allowed if definition contains any hostdevs */
- if (def->nhostdevs > 0) {
- virReportError(VIR_ERR_OPERATION_INVALID, "%s",
- _("domain has assigned host devices"));
- return false;
- }
-
- return true;
-}
-
char *
libxlDomainMigrationBegin(virConnectPtr conn,
virDomainObjPtr vm,
@@ -251,7 +238,7 @@ libxlDomainMigrationBegin(virConnectPtr conn,
def = vm->def;
}
- if (!libxlDomainMigrationIsAllowed(def))
+ if (libxlDomainHasHostDevices(def))
goto endjob;
xml = virDomainDefFormat(def, VIR_DOMAIN_DEF_FORMAT_SECURE);
--
2.1.0
9 years, 7 months
[libvirt] [PATCH] qemu: fix double free when fail to cold-plug a rng device
by Luyao Huang
https://bugzilla.redhat.com/show_bug.cgi?id=1220809
When cold-plug a rng device and get failed in qemuDomainAssignAddresses,
we will double free the rng device. Free the pointer after we Insert the
device success to fix this issue.
...
5 0x00007fb7d180ac8a in virFree at util/viralloc.c:582
6 0x00007fb7d1895cdd in virDomainRNGDefFree at conf/domain_conf.c:19786
7 0x00007fb7d1895d99 in virDomainDeviceDefFree at conf/domain_conf.c:2022
8 0x00007fb7b92b8baf in qemuDomainAttachDeviceFlags at qemu/qemu_driver.c:8785
9 0x00007fb7d190c5d7 in virDomainAttachDeviceFlags at libvirt-domain.c:8488
10 0x00007fb7d23af9d2 in remoteDispatchDomainAttachDeviceFlags at remote_dispatch.h:2842
...
Signed-off-by: Luyao Huang <lhuang(a)redhat.com>
---
src/qemu/qemu_driver.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 33c1cfd..f922a28 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -8359,11 +8359,10 @@ qemuDomainAttachDeviceConfig(virQEMUCapsPtr qemuCaps,
if (virDomainRNGInsert(vmdef, dev->data.rng, false) < 0)
return -1;
+ dev->data.rng = NULL;
if (qemuDomainAssignAddresses(vmdef, qemuCaps, NULL) < 0)
return -1;
-
- dev->data.rng = NULL;
break;
case VIR_DOMAIN_DEVICE_MEMORY:
--
1.8.3.1
9 years, 7 months
[libvirt] [PATCHv2] conf: fix no error when set an unsupport string in ./devices/shmem/msi[@ioeventfd]
by Luyao Huang
https://bugzilla.redhat.com/show_bug.cgi?id=1220265
Pass the return value to an enum directly is not safe.
When pass a invalid @ioeventfd and virTristateSwitchTypeFromString
return -1 to def->msi.ioeventfd, and this value transform to
4294967295, so no error when the parse failed.
To fix this issue, folter the value using int and then assign it
to virTristateSwitch as it's done.
Signed-off-by: Luyao Huang <lhuang(a)redhat.com>
---
v2:
a new way to fix this issue.
src/conf/domain_conf.c | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 4cd36a1..04cce50 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -10847,12 +10847,16 @@ virDomainShmemDefParseXML(xmlNodePtr node,
}
VIR_FREE(tmp);
- if ((tmp = virXMLPropString(msi, "ioeventfd")) &&
- (def->msi.ioeventfd = virTristateSwitchTypeFromString(tmp)) <= 0) {
- virReportError(VIR_ERR_XML_ERROR,
- _("invalid msi ioeventfd setting for shmem: '%s'"),
- tmp);
- goto cleanup;
+ if ((tmp = virXMLPropString(msi, "ioeventfd"))) {
+ int val;
+
+ if ((val = virTristateSwitchTypeFromString(tmp)) <= 0) {
+ virReportError(VIR_ERR_XML_ERROR,
+ _("invalid msi ioeventfd setting for shmem: '%s'"),
+ tmp);
+ goto cleanup;
+ }
+ def->msi.ioeventfd = val;
}
VIR_FREE(tmp);
}
--
1.8.3.1
9 years, 7 months
[libvirt] [PATCH] libxl: support VNC passwd
by Jim Fehlig
While implementing support for SPICE, noticed VNC passwd was never
copied to libxl_device_vfb's vnc.passwd field.
Signed-off-by: Jim Fehlig <jfehlig(a)suse.com>
---
src/libxl/libxl_conf.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index fccada5..35b1d04 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -1283,6 +1283,8 @@ libxlMakeVfb(virPortAllocatorPtr graphicsports,
if (VIR_STRDUP(x_vfb->vnc.listen, listenAddr) < 0)
return -1;
}
+ if (VIR_STRDUP(x_vfb->vnc.passwd, l_vfb->data.vnc.auth.passwd) < 0)
+ return -1;
if (VIR_STRDUP(x_vfb->keymap, l_vfb->data.vnc.keymap) < 0)
return -1;
break;
--
1.8.4.5
9 years, 7 months
[libvirt] [v3 0/2] Remove host name checking from iSCSI duplicate source checks
by John Ferlan
Only a v3 because the first two series "Addition host name check for
network storage pools" were not well received. If someone wants to
pick up/use the the hostname checking code from the v2, then have at it.
Patch 1, 2, 7, & 8 use the virSocketAddr code.
This series just focuses on the iSCSI duplicate source checks and in
particular the removal of the host name checks to be replaced primarily
by the duplicate source device path (or IQN) check. For iSCSI devices,
checking the resolved host name was not feasible. Instead, if the source
device path (IQN) of the new definition is the same as a running pool,
then the new definition will be rejected. The secondary check is for an
undocumented <inititor> element to define the initiator iqn (see bz 488142).
The first patch is "new" - it's something I discovered while doing some
extra testing with the v2 of the series.
The second patch provides the change and modifies the documentation. It
resolves two bz's as listed in the patch description.
v2 here:
http://www.redhat.com/archives/libvir-list/2015-April/msg01197.html
Much discussion took place in v1 though in 7/7:
http://www.redhat.com/archives/libvir-list/2015-April/msg00880.html
John Ferlan (2):
conf: Adjust duplicate source host port check
conf: Remove source host name check for iSCSI
docs/formatstorage.html.in | 18 ++++++++++++++----
docs/storage.html.in | 8 +++++++-
src/conf/storage_conf.c | 7 +++----
3 files changed, 24 insertions(+), 9 deletions(-)
--
2.1.0
9 years, 7 months