[libvirt] [PATCH v3] vhost-user: add support reconnect for vhost-user ports
by ZhiPeng Lu
For vhost-user ports, Open vSwitch acts as the server and QEMU the client.
When OVS crashes or restarts, the QEMU process should be reconnected to
OVS.
Signed-off-by: ZhiPeng Lu <lu.zhipeng(a)zte.com.cn>
---
docs/schemas/domaincommon.rng | 26 ++++++++------
src/conf/domain_conf.c | 40 ++++++++++++++++++----
src/conf/domain_conf.h | 10 +++---
src/qemu/qemu_command.c | 2 +-
src/qemu/qemu_domain.c | 2 +-
src/qemu/qemu_monitor_json.c | 2 +-
.../qemuxml2argv-net-vhostuser-multiq.args | 4 +--
.../qemuxml2argv-net-vhostuser-multiq.xml | 8 +++--
8 files changed, 65 insertions(+), 29 deletions(-)
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 76852ab..3f4ed82 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -2327,6 +2327,18 @@
</attribute>
</optional>
</define>
+ <define name="reconnect">
+ <element name="reconnect">
+ <attribute name="enabled">
+ <ref name="virYesNo"/>
+ </attribute>
+ <optional>
+ <attribute name="timeout">
+ <ref name="unsignedInt"/>
+ </attribute>
+ </optional>
+ </element>
+ </define>
<!--
An interface description can either be of type bridge in which case
@@ -2388,6 +2400,9 @@
<value>client</value>
</choice>
</attribute>
+ <optional>
+ <ref name="reconnect"/>
+ </optional>
<empty/>
</element>
<ref name="interface-options"/>
@@ -3636,16 +3651,7 @@
</attribute>
</optional>
<optional>
- <element name="reconnect">
- <attribute name="enabled">
- <ref name="virYesNo"/>
- </attribute>
- <optional>
- <attribute name="timeout">
- <ref name="unsignedInt"/>
- </attribute>
- </optional>
- </element>
+ <ref name="reconnect"/>
</optional>
<zeroOrMore>
<ref name='devSeclabel'/>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index cc5e79b..b7fc3a5 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -83,6 +83,13 @@ struct _virDomainXMLOption {
/* Private data for save image stored in snapshot XML */
virSaveCookieCallbacks saveCookie;
};
+static int
+virDomainDeviceSourceReconnectDefParseXML(virDomainDeviceSourceReconnectDefPtr def,
+ xmlNodePtr node,
+ xmlXPathContextPtr ctxt);
+static void
+virDomainDeviceSourceReconnectDefFormat(virBufferPtr buf,
+ virDomainDeviceSourceReconnectDefPtr def);
#define VIR_DOMAIN_DEF_FORMAT_COMMON_FLAGS \
(VIR_DOMAIN_DEF_FORMAT_SECURE | \
@@ -10245,6 +10252,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
virNWFilterHashTablePtr filterparams = NULL;
virDomainActualNetDefPtr actual = NULL;
xmlNodePtr oldnode = ctxt->node;
+ virDomainDeviceSourceReconnectDef reconnect = {0};
int rv, val;
if (VIR_ALLOC(def) < 0)
@@ -10331,6 +10339,8 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
vhostuser_type = virXMLPropString(cur, "type");
vhostuser_path = virXMLPropString(cur, "path");
vhostuser_mode = virXMLPropString(cur, "mode");
+ if (virDomainDeviceSourceReconnectDefParseXML(&reconnect, cur, ctxt) < 0)
+ goto error;
} else if (!def->virtPortProfile
&& virXMLNodeNameEqual(cur, "virtualport")) {
if (def->type == VIR_DOMAIN_NET_TYPE_NETWORK) {
@@ -10552,8 +10562,17 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
if (STREQ(vhostuser_mode, "server")) {
def->data.vhostuser->data.nix.listen = true;
+ if (reconnect.enabled != VIR_TRISTATE_BOOL_ABSENT) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("'reconnect' attribute unsupported "
+ "'server' mode for <interface type='vhostuser'>"));
+ goto error;
+ }
} else if (STREQ(vhostuser_mode, "client")) {
def->data.vhostuser->data.nix.listen = false;
+ def->data.vhostuser->data.nix.reconnect.enabled = reconnect.enabled;
+ def->data.vhostuser->data.nix.reconnect.timeout = reconnect.timeout;
+ reconnect.enabled = VIR_TRISTATE_BOOL_ABSENT;
} else {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("Wrong <source> 'mode' attribute "
@@ -11216,7 +11235,7 @@ virDomainChrDefParseTargetXML(virDomainChrDefPtr def,
}
static int
-virDomainChrSourceReconnectDefParseXML(virDomainChrSourceReconnectDefPtr def,
+virDomainDeviceSourceReconnectDefParseXML(virDomainDeviceSourceReconnectDefPtr def,
xmlNodePtr node,
xmlXPathContextPtr ctxt)
{
@@ -11338,7 +11357,7 @@ virDomainChrSourceDefParseTCP(virDomainChrSourceDefPtr def,
VIR_FREE(tmp);
}
- if (virDomainChrSourceReconnectDefParseXML(&def->data.tcp.reconnect,
+ if (virDomainDeviceSourceReconnectDefParseXML(&def->data.tcp.reconnect,
source,
ctxt) < 0) {
goto error;
@@ -11389,7 +11408,7 @@ virDomainChrSourceDefParseUnix(virDomainChrSourceDefPtr def,
def->data.nix.listen = mode == VIR_DOMAIN_CHR_SOURCE_MODE_BIND;
def->data.nix.path = virXMLPropString(source, "path");
- if (virDomainChrSourceReconnectDefParseXML(&def->data.nix.reconnect,
+ if (virDomainDeviceSourceReconnectDefParseXML(&def->data.nix.reconnect,
source,
ctxt) < 0) {
return -1;
@@ -22984,6 +23003,13 @@ virDomainNetDefFormat(virBufferPtr buf,
def->data.vhostuser->data.nix.listen ?
"server" : "client");
sourceLines++;
+ if (def->data.vhostuser->data.nix.reconnect.enabled != VIR_TRISTATE_BOOL_ABSENT) {
+ virBufferAddLit(buf, ">\n");
+ sourceLines++;
+ virBufferAdjustIndent(buf, 2);
+ virDomainDeviceSourceReconnectDefFormat(buf, &def->data.vhostuser->data.nix.reconnect);
+ virBufferAdjustIndent(buf, -2);
+ }
}
break;
@@ -23218,8 +23244,8 @@ virDomainChrAttrsDefFormat(virBufferPtr buf,
static void
-virDomainChrSourceReconnectDefFormat(virBufferPtr buf,
- virDomainChrSourceReconnectDefPtr def)
+virDomainDeviceSourceReconnectDefFormat(virBufferPtr buf,
+ virDomainDeviceSourceReconnectDefPtr def)
{
if (def->enabled == VIR_TRISTATE_BOOL_ABSENT)
return;
@@ -23314,7 +23340,7 @@ virDomainChrSourceDefFormat(virBufferPtr buf,
virBufferAsprintf(&attrBuf, " tlsFromConfig='%d'",
def->data.tcp.tlsFromConfig);
- virDomainChrSourceReconnectDefFormat(&childBuf,
+ virDomainDeviceSourceReconnectDefFormat(&childBuf,
&def->data.tcp.reconnect);
if (virXMLFormatElement(buf, "source", &attrBuf, &childBuf) < 0)
@@ -23333,7 +23359,7 @@ virDomainChrSourceDefFormat(virBufferPtr buf,
virDomainSourceDefFormatSeclabel(&childBuf, def->nseclabels,
def->seclabels, flags);
- virDomainChrSourceReconnectDefFormat(&childBuf,
+ virDomainDeviceSourceReconnectDefFormat(&childBuf,
&def->data.nix.reconnect);
if (virXMLFormatElement(buf, "source", &attrBuf, &childBuf) < 0)
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index bb3b6f0..909f60d 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1138,12 +1138,12 @@ typedef enum {
} virDomainChrSpicevmcName;
-struct _virDomainChrSourceReconnectDef {
+struct _virDomainDeviceSourceReconnectDef {
virTristateBool enabled;
unsigned int timeout;
};
-typedef struct _virDomainChrSourceReconnectDef virDomainChrSourceReconnectDef;
-typedef virDomainChrSourceReconnectDef *virDomainChrSourceReconnectDefPtr;
+typedef struct _virDomainDeviceSourceReconnectDef virDomainDeviceSourceReconnectDef;
+typedef virDomainDeviceSourceReconnectDef *virDomainDeviceSourceReconnectDefPtr;
/* The host side information for a character device. */
@@ -1168,7 +1168,7 @@ struct _virDomainChrSourceDef {
bool tlscreds;
int haveTLS; /* enum virTristateBool */
bool tlsFromConfig;
- virDomainChrSourceReconnectDef reconnect;
+ virDomainDeviceSourceReconnectDef reconnect;
} tcp;
struct {
char *bindHost;
@@ -1179,7 +1179,7 @@ struct _virDomainChrSourceDef {
struct {
char *path;
bool listen;
- virDomainChrSourceReconnectDef reconnect;
+ virDomainDeviceSourceReconnectDef reconnect;
} nix;
int spicevmc;
struct {
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 9b3e3fc..4640ce8 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -5094,7 +5094,7 @@ qemuBuildChrChardevFileStr(virLogManagerPtr logManager,
static void
qemuBuildChrChardevReconnectStr(virBufferPtr buf,
- const virDomainChrSourceReconnectDef *def)
+ const virDomainDeviceSourceReconnectDef *def)
{
if (def->enabled == VIR_TRISTATE_BOOL_YES) {
virBufferAsprintf(buf, ",reconnect=%u", def->timeout);
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 50b536e..4ea0727 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -3244,7 +3244,7 @@ qemuDomainNetSupportsCoalesce(virDomainNetType type)
static int
-qemuDomainChrSourceReconnectDefValidate(const virDomainChrSourceReconnectDef *def)
+qemuDomainChrSourceReconnectDefValidate(const virDomainDeviceSourceReconnectDef *def)
{
if (def->enabled == VIR_TRISTATE_BOOL_YES &&
def->timeout == 0) {
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 63b8559..b3d572e 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -6443,7 +6443,7 @@ int qemuMonitorJSONGetTPMTypes(qemuMonitorPtr mon,
static int
qemuMonitorJSONBuildChrChardevReconnect(virJSONValuePtr object,
- const virDomainChrSourceReconnectDef *def)
+ const virDomainDeviceSourceReconnectDef *def)
{
if (def->enabled != VIR_TRISTATE_BOOL_YES)
return 0;
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser-multiq.args b/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser-multiq.args
index b69ebd8..0b08f44 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser-multiq.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser-multiq.args
@@ -25,14 +25,14 @@ server,nowait \
-netdev vhost-user,chardev=charnet0,id=hostnet0 \
-device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:ee:96:6b,bus=pci.0,\
addr=0x3 \
--chardev socket,id=charnet1,path=/tmp/vhost1.sock \
+-chardev socket,id=charnet1,path=/tmp/vhost1.sock,reconnect=10 \
-netdev vhost-user,chardev=charnet1,id=hostnet1 \
-device virtio-net-pci,netdev=hostnet1,id=net1,mac=52:54:00:ee:96:6c,bus=pci.0,\
addr=0x4 \
-netdev socket,listen=:2015,id=hostnet2 \
-device rtl8139,netdev=hostnet2,id=net2,mac=52:54:00:95:db:c0,bus=pci.0,\
addr=0x5 \
--chardev socket,id=charnet3,path=/tmp/vhost2.sock \
+-chardev socket,id=charnet3,path=/tmp/vhost2.sock,reconnect=0 \
-netdev vhost-user,chardev=charnet3,queues=4,id=hostnet3 \
-device virtio-net-pci,mq=on,vectors=10,netdev=hostnet3,id=net3,\
mac=52:54:00:ee:96:6d,bus=pci.0,addr=0x6
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser-multiq.xml b/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser-multiq.xml
index d5c42fe..2fadb1c 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser-multiq.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser-multiq.xml
@@ -30,7 +30,9 @@
</interface>
<interface type='vhostuser'>
<mac address='52:54:00:ee:96:6c'/>
- <source type='unix' path='/tmp/vhost1.sock' mode='client'/>
+ <source type='unix' path='/tmp/vhost1.sock' mode='client'>
+ <reconnect enabled='yes' timeout='10'/>
+ </source>
<model type='virtio'/>
</interface>
<interface type='server'>
@@ -40,7 +42,9 @@
</interface>
<interface type='vhostuser'>
<mac address='52:54:00:ee:96:6d'/>
- <source type='unix' path='/tmp/vhost2.sock' mode='client'/>
+ <source type='unix' path='/tmp/vhost2.sock' mode='client'>
+ <reconnect enabled='no'/>
+ </source>
<model type='virtio'/>
<driver queues='4'/>
</interface>
--
1.8.3.1
7 years, 2 months
[libvirt] [PATCH 0/2] udp chardev fixes
by Ján Tomko
Ján Tomko (2):
conf: fix formatting of udp chardev attributes
qemu: fix hotplug of udp device with no connect host
src/conf/domain_conf.c | 12 ++++--------
src/qemu/qemu_monitor_json.c | 5 ++++-
tests/genericxml2xmloutdata/generic-chardev-udp.xml | 2 +-
3 files changed, 9 insertions(+), 10 deletions(-)
--
2.13.0
7 years, 2 months
[libvirt] [PATCH] qemu: adjust indentation of qemuDomainObjPrivateXMLFormatAutomaticPlacement
by Ján Tomko
Commit 6801da94 fixed the typo in the function name, but forgot
to adjust the indentation level of the next line.
---
Pushed as trivial.
src/qemu/qemu_domain.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index a095d6e98..0b094a15e 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -1797,7 +1797,7 @@ qemuDomainObjPrivateXMLFormatVcpus(virBufferPtr buf,
static int
qemuDomainObjPrivateXMLFormatAutomaticPlacement(virBufferPtr buf,
- qemuDomainObjPrivatePtr priv)
+ qemuDomainObjPrivatePtr priv)
{
char *nodeset = NULL;
char *cpuset = NULL;
--
2.13.0
7 years, 2 months
[libvirt] [PATCH] qemu: domain: Fix typo in qemuDomainObjPtrivateXMLFormatAutomaticPlacement
by Peter Krempa
---
Pushed as trivial.
src/qemu/qemu_domain.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index cb371f1e8..a095d6e98 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -1796,7 +1796,7 @@ qemuDomainObjPrivateXMLFormatVcpus(virBufferPtr buf,
static int
-qemuDomainObjPtrivateXMLFormatAutomaticPlacement(virBufferPtr buf,
+qemuDomainObjPrivateXMLFormatAutomaticPlacement(virBufferPtr buf,
qemuDomainObjPrivatePtr priv)
{
char *nodeset = NULL;
@@ -1937,7 +1937,7 @@ qemuDomainObjPrivateXMLFormat(virBufferPtr buf,
virBufferAddLit(buf, "</devices>\n");
}
- if (qemuDomainObjPtrivateXMLFormatAutomaticPlacement(buf, priv) < 0)
+ if (qemuDomainObjPrivateXMLFormatAutomaticPlacement(buf, priv) < 0)
return -1;
/* Various per-domain paths */
--
2.14.1
7 years, 2 months
[libvirt] [PATCH] conf: fix formatting of udp chardev attributes
by Ján Tomko
It is possible (although possibly not very useful) to leave out
the service attribute when using <source mode='bind'/>
Fix the formatter bug introduced by commit 4a0da34 and format
the host when its present (checked for non-NULL inside
virBufferEscapeString) instead of basing it on the presence
of the service attribute.
https://bugzilla.redhat.com/show_bug.cgi?id=1455825
---
src/conf/domain_conf.c | 12 ++++--------
tests/genericxml2xmloutdata/generic-chardev-udp.xml | 2 +-
2 files changed, 5 insertions(+), 9 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 44cfb52b4..3c3db7291 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -23307,19 +23307,15 @@ virDomainChrSourceDefFormat(virBufferPtr buf,
case VIR_DOMAIN_CHR_TYPE_UDP:
if (def->data.udp.bindService || def->data.udp.bindHost) {
virBufferAddLit(buf, "<source mode='bind'");
- if (def->data.udp.bindService)
- virBufferEscapeString(buf, " host='%s'", def->data.udp.bindHost);
- if (def->data.udp.bindService)
- virBufferEscapeString(buf, " service='%s'", def->data.udp.bindService);
+ virBufferEscapeString(buf, " host='%s'", def->data.udp.bindHost);
+ virBufferEscapeString(buf, " service='%s'", def->data.udp.bindService);
virBufferAddLit(buf, "/>\n");
}
if (def->data.udp.connectService || def->data.udp.connectHost) {
virBufferAddLit(buf, "<source mode='connect'");
- if (def->data.udp.connectService)
- virBufferEscapeString(buf, " host='%s'", def->data.udp.connectHost);
- if (def->data.udp.connectService)
- virBufferEscapeString(buf, " service='%s'", def->data.udp.connectService);
+ virBufferEscapeString(buf, " host='%s'", def->data.udp.connectHost);
+ virBufferEscapeString(buf, " service='%s'", def->data.udp.connectService);
virBufferAddLit(buf, "/>\n");
}
break;
diff --git a/tests/genericxml2xmloutdata/generic-chardev-udp.xml b/tests/genericxml2xmloutdata/generic-chardev-udp.xml
index c4a719f2f..c9b3e5550 100644
--- a/tests/genericxml2xmloutdata/generic-chardev-udp.xml
+++ b/tests/genericxml2xmloutdata/generic-chardev-udp.xml
@@ -29,7 +29,7 @@
<target type='virtio' name='test3'/>
</channel>
<channel type='udp'>
- <source mode='bind'/>
+ <source mode='bind' host='localhost'/>
<source mode='connect' service='5678'/>
<target type='virtio' name='test4'/>
</channel>
--
2.13.0
7 years, 2 months
[libvirt] [PATCH] vhost-user: add support reconnect for vhost-user ports
by ZhiPeng Lu
For vhost-user ports, Open vSwitch acts as the server and QEMU the client.
When OVS crashed or restart, QEMU shoule be reconnect to OVS.
Signed-off-by: ZhiPeng Lu <lu.zhipeng(a)zte.com.cn>
---
v1->v2:
- modify xml format
---
---
docs/schemas/domaincommon.rng | 12 ++++++++++
src/conf/domain_conf.c | 26 ++++++++++++++++++++++
.../qemuxml2argv-net-vhostuser-multiq.args | 4 ++--
.../qemuxml2argv-net-vhostuser-multiq.xml | 8 +++++--
4 files changed, 46 insertions(+), 4 deletions(-)
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 76852ab..bf015ca 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -2388,6 +2388,18 @@
<value>client</value>
</choice>
</attribute>
+ <optional>
+ <element name="reconnect">
+ <attribute name="enabled">
+ <ref name="virYesNo"/>
+ </attribute>
+ <optional>
+ <attribute name="timeout">
+ <ref name="unsignedInt"/>
+ </attribute>
+ </optional>
+ </element>
+ </optional>
<empty/>
</element>
<ref name="interface-options"/>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index cc5e79b..d121a9e 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -83,6 +83,13 @@ struct _virDomainXMLOption {
/* Private data for save image stored in snapshot XML */
virSaveCookieCallbacks saveCookie;
};
+static int
+virDomainChrSourceReconnectDefParseXML(virDomainChrSourceReconnectDefPtr def,
+ xmlNodePtr node,
+ xmlXPathContextPtr ctxt);
+static void
+virDomainChrSourceReconnectDefFormat(virBufferPtr buf,
+ virDomainChrSourceReconnectDefPtr def);
#define VIR_DOMAIN_DEF_FORMAT_COMMON_FLAGS \
(VIR_DOMAIN_DEF_FORMAT_SECURE | \
@@ -10245,6 +10252,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
virNWFilterHashTablePtr filterparams = NULL;
virDomainActualNetDefPtr actual = NULL;
xmlNodePtr oldnode = ctxt->node;
+ virDomainChrSourceReconnectDef reconnect = {0};
int rv, val;
if (VIR_ALLOC(def) < 0)
@@ -10331,6 +10339,8 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
vhostuser_type = virXMLPropString(cur, "type");
vhostuser_path = virXMLPropString(cur, "path");
vhostuser_mode = virXMLPropString(cur, "mode");
+ if (virDomainChrSourceReconnectDefParseXML(&reconnect, cur, ctxt) < 0)
+ goto error;
} else if (!def->virtPortProfile
&& virXMLNodeNameEqual(cur, "virtualport")) {
if (def->type == VIR_DOMAIN_NET_TYPE_NETWORK) {
@@ -10552,8 +10562,17 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
if (STREQ(vhostuser_mode, "server")) {
def->data.vhostuser->data.nix.listen = true;
+ if (reconnect.enabled != VIR_TRISTATE_BOOL_ABSENT) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("'reconnect' attribute unsupported "
+ "'server' mode for <interface type='vhostuser'>"));
+ goto error;
+ }
} else if (STREQ(vhostuser_mode, "client")) {
def->data.vhostuser->data.nix.listen = false;
+ def->data.vhostuser->data.nix.reconnect.enabled = reconnect.enabled;
+ def->data.vhostuser->data.nix.reconnect.timeout = reconnect.timeout;
+ reconnect.enabled = VIR_TRISTATE_BOOL_ABSENT;
} else {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("Wrong <source> 'mode' attribute "
@@ -22984,6 +23003,13 @@ virDomainNetDefFormat(virBufferPtr buf,
def->data.vhostuser->data.nix.listen ?
"server" : "client");
sourceLines++;
+ if (def->data.vhostuser->data.nix.reconnect.enabled != VIR_TRISTATE_BOOL_ABSENT) {
+ virBufferAddLit(buf, ">\n");
+ sourceLines++;
+ virBufferAdjustIndent(buf, 2);
+ virDomainChrSourceReconnectDefFormat(buf, &def->data.vhostuser->data.nix.reconnect);
+ virBufferAdjustIndent(buf, -2);
+ }
}
break;
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser-multiq.args b/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser-multiq.args
index b69ebd8..0b08f44 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser-multiq.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser-multiq.args
@@ -25,14 +25,14 @@ server,nowait \
-netdev vhost-user,chardev=charnet0,id=hostnet0 \
-device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:ee:96:6b,bus=pci.0,\
addr=0x3 \
--chardev socket,id=charnet1,path=/tmp/vhost1.sock \
+-chardev socket,id=charnet1,path=/tmp/vhost1.sock,reconnect=10 \
-netdev vhost-user,chardev=charnet1,id=hostnet1 \
-device virtio-net-pci,netdev=hostnet1,id=net1,mac=52:54:00:ee:96:6c,bus=pci.0,\
addr=0x4 \
-netdev socket,listen=:2015,id=hostnet2 \
-device rtl8139,netdev=hostnet2,id=net2,mac=52:54:00:95:db:c0,bus=pci.0,\
addr=0x5 \
--chardev socket,id=charnet3,path=/tmp/vhost2.sock \
+-chardev socket,id=charnet3,path=/tmp/vhost2.sock,reconnect=0 \
-netdev vhost-user,chardev=charnet3,queues=4,id=hostnet3 \
-device virtio-net-pci,mq=on,vectors=10,netdev=hostnet3,id=net3,\
mac=52:54:00:ee:96:6d,bus=pci.0,addr=0x6
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser-multiq.xml b/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser-multiq.xml
index d5c42fe..2fadb1c 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser-multiq.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-net-vhostuser-multiq.xml
@@ -30,7 +30,9 @@
</interface>
<interface type='vhostuser'>
<mac address='52:54:00:ee:96:6c'/>
- <source type='unix' path='/tmp/vhost1.sock' mode='client'/>
+ <source type='unix' path='/tmp/vhost1.sock' mode='client'>
+ <reconnect enabled='yes' timeout='10'/>
+ </source>
<model type='virtio'/>
</interface>
<interface type='server'>
@@ -40,7 +42,9 @@
</interface>
<interface type='vhostuser'>
<mac address='52:54:00:ee:96:6d'/>
- <source type='unix' path='/tmp/vhost2.sock' mode='client'/>
+ <source type='unix' path='/tmp/vhost2.sock' mode='client'>
+ <reconnect enabled='no'/>
+ </source>
<model type='virtio'/>
<driver queues='4'/>
</interface>
--
1.8.3.1
7 years, 2 months
[libvirt] [PATCH 0/4] qemu: Watchdog plug/unplug
by Michal Privoznik
For the hotplug case we need this qemu patch too:
http://lists.nongnu.org/archive/html/qemu-devel/2017-09/msg00856.html
so that we can actually set the action that watchdog is supposed to take when
it hits the timeout. But apart from that, nothing special is going on.
Michal Privoznik (4):
qemu: cold-plug of watchdog
qemu: cold-unplug of watchdog
qemu: hot-plug of watchdog
qemu: hot-unplug of watchdog
src/libvirt_private.syms | 1 +
src/qemu/qemu_alias.c | 15 ++-
src/qemu/qemu_alias.h | 2 +
src/qemu/qemu_command.c | 2 +-
src/qemu/qemu_command.h | 3 +
src/qemu/qemu_driver.c | 38 ++++++-
src/qemu/qemu_hotplug.c | 125 +++++++++++++++++++++
src/qemu/qemu_hotplug.h | 6 +
src/qemu/qemu_monitor.c | 12 ++
src/qemu/qemu_monitor.h | 2 +
src/qemu/qemu_monitor_json.c | 28 +++++
src/qemu/qemu_monitor_json.h | 3 +
tests/qemuhotplugtest.c | 14 ++-
.../qemuhotplug-watchdog-full.xml | 3 +
.../qemuhotplug-watchdog.xml | 1 +
.../qemuhotplug-base-live+watchdog.xml | 55 +++++++++
16 files changed, 303 insertions(+), 7 deletions(-)
create mode 100644 tests/qemuhotplugtestdevices/qemuhotplug-watchdog-full.xml
create mode 100644 tests/qemuhotplugtestdevices/qemuhotplug-watchdog.xml
create mode 100644 tests/qemuhotplugtestdomains/qemuhotplug-base-live+watchdog.xml
--
2.13.5
7 years, 2 months
[libvirt] [PATCH python] Fix comparisons between signed & unsigned integers
by Daniel P. Berrange
When python3 builds C modules, it adds the -Wsign-compare flag to GCC.
This creates lots of warnings where we compare a 'size_t' value against
an 'int' value due to signed/unsigned difference. Change all the size_t
types to ssize_t to address this.
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
libvirt-lxc-override.c | 2 +-
libvirt-override.c | 108 ++++++++++++++++++++++++-------------------------
libvirt-utils.c | 8 ++--
typewrappers.c | 2 +-
4 files changed, 60 insertions(+), 60 deletions(-)
diff --git a/libvirt-lxc-override.c b/libvirt-lxc-override.c
index 316a500..60c2e48 100644
--- a/libvirt-lxc-override.c
+++ b/libvirt-lxc-override.c
@@ -63,7 +63,7 @@ libvirt_lxc_virDomainLxcOpenNamespace(PyObject *self ATTRIBUTE_UNUSED,
unsigned int flags;
int c_retval;
int *fdlist = NULL;
- size_t i;
+ ssize_t i;
if (!PyArg_ParseTuple(args, (char *)"OI:virDomainLxcOpenNamespace",
&pyobj_domain, &flags))
diff --git a/libvirt-override.c b/libvirt-override.c
index 9eba4ed..bde7f4b 100644
--- a/libvirt-override.c
+++ b/libvirt-override.c
@@ -187,7 +187,7 @@ libvirt_virDomainGetCPUStats(PyObject *self ATTRIBUTE_UNUSED,
PyObject *error = NULL;
int ncpus = -1, start_cpu = 0;
int sumparams = 0, nparams = -1;
- size_t i;
+ ssize_t i;
int i_retval;
unsigned int flags;
bool totalflag;
@@ -354,7 +354,7 @@ libvirt_virDomainMemoryStats(PyObject *self ATTRIBUTE_UNUSED,
virDomainPtr domain;
PyObject *pyobj_domain;
unsigned int nr_stats;
- size_t i;
+ ssize_t i;
virDomainMemoryStatStruct stats[VIR_DOMAIN_MEMORY_STAT_NR];
PyObject *info;
PyObject *key = NULL, *val = NULL;
@@ -365,7 +365,7 @@ libvirt_virDomainMemoryStats(PyObject *self ATTRIBUTE_UNUSED,
nr_stats = virDomainMemoryStats(domain, stats,
VIR_DOMAIN_MEMORY_STAT_NR, 0);
- if (nr_stats == -1)
+ if (nr_stats == (unsigned int)-1)
return VIR_PY_NONE;
/* convert to a Python dictionary */
@@ -1204,7 +1204,7 @@ libvirt_virDomainGetVcpus(PyObject *self ATTRIBUTE_UNUSED,
virDomainInfo dominfo;
virVcpuInfoPtr cpuinfo = NULL;
unsigned char *cpumap = NULL;
- size_t cpumaplen, i;
+ ssize_t cpumaplen, i;
int i_retval, cpunum;
if (!PyArg_ParseTuple(args, (char *)"O:virDomainGetVcpus",
@@ -1274,7 +1274,7 @@ libvirt_virDomainGetVcpus(PyObject *self ATTRIBUTE_UNUSED,
}
for (i = 0; i < dominfo.nrVirtCpu; i++) {
PyObject *info = PyTuple_New(cpunum);
- size_t j;
+ ssize_t j;
if (info == NULL)
goto cleanup;
@@ -1384,7 +1384,7 @@ libvirt_virDomainGetVcpuPinInfo(PyObject *self ATTRIBUTE_UNUSED,
PyObject *pyobj_domain, *pycpumaps = NULL, *error = NULL;
virDomainInfo dominfo;
unsigned char *cpumaps = NULL;
- size_t cpumaplen, vcpu, pcpu;
+ ssize_t cpumaplen, vcpu, pcpu;
unsigned int flags;
int i_retval, cpunum;
@@ -1496,8 +1496,8 @@ libvirt_virDomainGetEmulatorPinInfo(PyObject *self ATTRIBUTE_UNUSED,
PyObject *pyobj_domain;
PyObject *pycpumap;
unsigned char *cpumap;
- size_t cpumaplen;
- size_t pcpu;
+ ssize_t cpumaplen;
+ ssize_t pcpu;
unsigned int flags;
int ret;
int cpunum;
@@ -1560,7 +1560,7 @@ libvirt_virDomainGetIOThreadInfo(PyObject *self ATTRIBUTE_UNUSED,
PyObject *py_iothrinfo = NULL;
virDomainIOThreadInfoPtr *iothrinfo = NULL;
unsigned int flags;
- size_t pcpu, i;
+ ssize_t pcpu, i;
int niothreads, cpunum;
if (!PyArg_ParseTuple(args, (char *)"OI:virDomainGetIOThreadInfo",
@@ -1846,7 +1846,7 @@ virConnectCredCallbackWrapper(virConnectCredentialPtr cred,
PyObject *pycb;
PyObject *pyret = NULL;
int ret = -1;
- size_t i;
+ ssize_t i;
LIBVIRT_ENSURE_THREAD_STATE;
@@ -1953,7 +1953,7 @@ libvirt_virConnectOpenAuth(PyObject *self ATTRIBUTE_UNUSED,
auth.ncredtype = PyList_Size(pycredtype);
if (auth.ncredtype) {
- size_t i;
+ ssize_t i;
if (VIR_ALLOC_N(auth.credtype, auth.ncredtype) < 0)
return PyErr_NoMemory();
for (i = 0; i < auth.ncredtype; i++) {
@@ -2046,7 +2046,7 @@ libvirt_virConnectGetCPUModelNames(PyObject *self ATTRIBUTE_UNUSED,
virConnectPtr conn;
PyObject *rv = NULL, *pyobj_conn;
char **models = NULL;
- size_t i;
+ ssize_t i;
unsigned int flags = 0;
const char *arch = NULL;
@@ -2117,7 +2117,7 @@ libvirt_virConnectListDomainsID(PyObject *self ATTRIBUTE_UNUSED,
{
PyObject *py_retval;
int *ids = NULL, c_retval;
- size_t i;
+ ssize_t i;
virConnectPtr conn;
PyObject *pyobj_conn;
@@ -2172,7 +2172,7 @@ libvirt_virConnectListAllDomains(PyObject *self ATTRIBUTE_UNUSED,
virConnectPtr conn;
virDomainPtr *doms = NULL;
int c_retval = 0;
- size_t i;
+ ssize_t i;
unsigned int flags;
if (!PyArg_ParseTuple(args, (char *)"OI:virConnectListAllDomains",
@@ -2215,7 +2215,7 @@ libvirt_virConnectListDefinedDomains(PyObject *self ATTRIBUTE_UNUSED,
PyObject *py_retval;
char **names = NULL;
int c_retval;
- size_t i;
+ ssize_t i;
virConnectPtr conn;
PyObject *pyobj_conn;
@@ -2271,7 +2271,7 @@ libvirt_virDomainSnapshotListNames(PyObject *self ATTRIBUTE_UNUSED,
PyObject *py_retval;
char **names = NULL;
int c_retval;
- size_t i;
+ ssize_t i;
virDomainPtr dom;
PyObject *pyobj_dom;
unsigned int flags;
@@ -2325,7 +2325,7 @@ libvirt_virDomainListAllSnapshots(PyObject *self ATTRIBUTE_UNUSED,
PyObject *py_retval = NULL;
virDomainSnapshotPtr *snaps = NULL;
int c_retval;
- size_t i;
+ ssize_t i;
virDomainPtr dom;
PyObject *pyobj_dom;
unsigned int flags;
@@ -2370,7 +2370,7 @@ libvirt_virDomainSnapshotListChildrenNames(PyObject *self ATTRIBUTE_UNUSED,
PyObject *py_retval;
char **names = NULL;
int c_retval;
- size_t i;
+ ssize_t i;
virDomainSnapshotPtr snap;
PyObject *pyobj_snap;
unsigned int flags;
@@ -2425,7 +2425,7 @@ libvirt_virDomainSnapshotListAllChildren(PyObject *self ATTRIBUTE_UNUSED,
PyObject *py_retval = NULL;
virDomainSnapshotPtr *snaps = NULL;
int c_retval;
- size_t i;
+ ssize_t i;
virDomainSnapshotPtr parent;
PyObject *pyobj_parent;
unsigned int flags;
@@ -2762,7 +2762,7 @@ libvirt_virDomainGetSecurityLabelList(PyObject *self ATTRIBUTE_UNUSED,
virDomainPtr dom;
PyObject *pyobj_dom;
virSecurityLabel *labels = NULL;
- size_t i;
+ ssize_t i;
if (!PyArg_ParseTuple(args, (char *)"O:virDomainGetSecurityLabelList",
&pyobj_dom))
@@ -2889,7 +2889,7 @@ libvirt_virConnectListNetworks(PyObject *self ATTRIBUTE_UNUSED,
PyObject *py_retval;
char **names = NULL;
int c_retval;
- size_t i;
+ ssize_t i;
virConnectPtr conn;
PyObject *pyobj_conn;
@@ -2945,7 +2945,7 @@ libvirt_virConnectListDefinedNetworks(PyObject *self ATTRIBUTE_UNUSED,
PyObject *py_retval;
char **names = NULL;
int c_retval;
- size_t i;
+ ssize_t i;
virConnectPtr conn;
PyObject *pyobj_conn;
@@ -3002,7 +3002,7 @@ libvirt_virConnectListAllNetworks(PyObject *self ATTRIBUTE_UNUSED,
virConnectPtr conn;
virNetworkPtr *nets = NULL;
int c_retval = 0;
- size_t i;
+ ssize_t i;
unsigned int flags;
if (!PyArg_ParseTuple(args, (char *)"OI:virConnectListAllNetworks",
@@ -3172,7 +3172,7 @@ libvirt_virNodeGetCellsFreeMemory(PyObject *self ATTRIBUTE_UNUSED,
PyObject *py_retval;
PyObject *pyobj_conn;
int startCell, maxCells, c_retval;
- size_t i;
+ ssize_t i;
virConnectPtr conn;
unsigned long long *freeMems;
@@ -3223,7 +3223,7 @@ libvirt_virNodeGetCPUStats(PyObject *self ATTRIBUTE_UNUSED,
virConnectPtr conn;
unsigned int flags;
int cpuNum, c_retval;
- size_t i;
+ ssize_t i;
int nparams = 0;
virNodeCPUStatsPtr stats = NULL;
@@ -3281,7 +3281,7 @@ libvirt_virNodeGetMemoryStats(PyObject *self ATTRIBUTE_UNUSED,
virConnectPtr conn;
unsigned int flags;
int cellNum, c_retval;
- size_t i;
+ ssize_t i;
int nparams = 0;
virNodeMemoryStatsPtr stats = NULL;
@@ -3335,7 +3335,7 @@ libvirt_virConnectListStoragePools(PyObject *self ATTRIBUTE_UNUSED,
PyObject *py_retval;
char **names = NULL;
int c_retval;
- size_t i;
+ ssize_t i;
virConnectPtr conn;
PyObject *pyobj_conn;
@@ -3389,7 +3389,7 @@ libvirt_virConnectListDefinedStoragePools(PyObject *self ATTRIBUTE_UNUSED,
PyObject *py_retval;
char **names = NULL;
int c_retval;
- size_t i;
+ ssize_t i;
virConnectPtr conn;
PyObject *pyobj_conn;
@@ -3447,7 +3447,7 @@ libvirt_virConnectListAllStoragePools(PyObject *self ATTRIBUTE_UNUSED,
virConnectPtr conn;
virStoragePoolPtr *pools = NULL;
int c_retval = 0;
- size_t i;
+ ssize_t i;
unsigned int flags;
if (!PyArg_ParseTuple(args, (char *)"OI:virConnectListAllStoragePools",
@@ -3491,7 +3491,7 @@ libvirt_virStoragePoolListVolumes(PyObject *self ATTRIBUTE_UNUSED,
PyObject *py_retval;
char **names = NULL;
int c_retval;
- size_t i;
+ ssize_t i;
virStoragePoolPtr pool;
PyObject *pyobj_pool;
@@ -3548,7 +3548,7 @@ libvirt_virStoragePoolListAllVolumes(PyObject *self ATTRIBUTE_UNUSED,
virStoragePoolPtr pool;
virStorageVolPtr *vols = NULL;
int c_retval = 0;
- size_t i;
+ ssize_t i;
unsigned int flags;
PyObject *pyobj_pool;
@@ -3812,7 +3812,7 @@ libvirt_virNodeListDevices(PyObject *self ATTRIBUTE_UNUSED,
PyObject *py_retval;
char **names = NULL;
int c_retval;
- size_t i;
+ ssize_t i;
virConnectPtr conn;
PyObject *pyobj_conn;
char *cap;
@@ -3873,7 +3873,7 @@ libvirt_virConnectListAllNodeDevices(PyObject *self ATTRIBUTE_UNUSED,
virConnectPtr conn;
virNodeDevicePtr *devices = NULL;
int c_retval = 0;
- size_t i;
+ ssize_t i;
unsigned int flags;
if (!PyArg_ParseTuple(args, (char *)"OI:virConnectListAllNodeDevices",
@@ -3917,7 +3917,7 @@ libvirt_virNodeDeviceListCaps(PyObject *self ATTRIBUTE_UNUSED,
PyObject *py_retval;
char **names = NULL;
int c_retval;
- size_t i;
+ ssize_t i;
virNodeDevicePtr dev;
PyObject *pyobj_dev;
@@ -4048,7 +4048,7 @@ libvirt_virConnectListSecrets(PyObject *self ATTRIBUTE_UNUSED,
char **uuids = NULL;
virConnectPtr conn;
int c_retval;
- size_t i;
+ ssize_t i;
PyObject *pyobj_conn;
if (!PyArg_ParseTuple(args, (char *)"O:virConnectListSecrets", &pyobj_conn))
@@ -4104,7 +4104,7 @@ libvirt_virConnectListAllSecrets(PyObject *self ATTRIBUTE_UNUSED,
virConnectPtr conn;
virSecretPtr *secrets = NULL;
int c_retval = 0;
- size_t i;
+ ssize_t i;
unsigned int flags;
if (!PyArg_ParseTuple(args, (char *)"OI:virConnectListAllSecrets",
@@ -4280,7 +4280,7 @@ libvirt_virConnectListNWFilters(PyObject *self ATTRIBUTE_UNUSED,
char **uuids = NULL;
virConnectPtr conn;
int c_retval;
- size_t i;
+ ssize_t i;
PyObject *pyobj_conn;
if (!PyArg_ParseTuple(args, (char *)"O:virConnectListNWFilters",
@@ -4337,7 +4337,7 @@ libvirt_virConnectListAllNWFilters(PyObject *self ATTRIBUTE_UNUSED,
virConnectPtr conn;
virNWFilterPtr *filters = NULL;
int c_retval = 0;
- size_t i;
+ ssize_t i;
unsigned int flags;
if (!PyArg_ParseTuple(args, (char *)"OI:virConnectListAllNWFilters",
@@ -4381,7 +4381,7 @@ libvirt_virConnectListInterfaces(PyObject *self ATTRIBUTE_UNUSED,
PyObject *py_retval;
char **names = NULL;
int c_retval;
- size_t i;
+ ssize_t i;
virConnectPtr conn;
PyObject *pyobj_conn;
@@ -4438,7 +4438,7 @@ libvirt_virConnectListDefinedInterfaces(PyObject *self ATTRIBUTE_UNUSED,
PyObject *py_retval;
char **names = NULL;
int c_retval;
- size_t i;
+ ssize_t i;
virConnectPtr conn;
PyObject *pyobj_conn;
@@ -4499,7 +4499,7 @@ libvirt_virConnectListAllInterfaces(PyObject *self ATTRIBUTE_UNUSED,
virConnectPtr conn;
virInterfacePtr *ifaces = NULL;
int c_retval = 0;
- size_t i;
+ ssize_t i;
unsigned int flags;
if (!PyArg_ParseTuple(args, (char *)"OI:virConnectListAllInterfaces",
@@ -4548,7 +4548,7 @@ libvirt_virConnectBaselineCPU(PyObject *self ATTRIBUTE_UNUSED,
int ncpus = 0;
char *base_cpu;
PyObject *pybase_cpu;
- size_t i, j;
+ ssize_t i, j;
if (!PyArg_ParseTuple(args, (char *)"OOI:virConnectBaselineCPU",
&pyobj_conn, &list, &flags))
@@ -4864,7 +4864,7 @@ libvirt_virDomainGetDiskErrors(PyObject *self ATTRIBUTE_UNUSED,
virDomainDiskErrorPtr disks = NULL;
unsigned int ndisks;
int count;
- size_t i;
+ ssize_t i;
if (!PyArg_ParseTuple(args, (char *) "OI:virDomainGetDiskErrors",
&pyobj_domain, &flags))
@@ -4925,7 +4925,7 @@ libvirt_virDomainInterfaceAddresses(PyObject *self ATTRIBUTE_UNUSED,
unsigned int source;
unsigned int flags;
int ifaces_count = 0;
- size_t i, j;
+ ssize_t i, j;
if (!PyArg_ParseTuple(args, (char *) "OII:virDomainInterfaceAddresses",
&pyobj_domain, &source, &flags))
@@ -6020,7 +6020,7 @@ libvirt_virConnectDomainEventGraphicsCallback(virConnectPtr conn ATTRIBUTE_UNUSE
PyObject *pyobj_remote = NULL;
PyObject *pyobj_subject = NULL;
int ret = -1;
- size_t i;
+ ssize_t i;
LIBVIRT_ENSURE_THREAD_STATE;
@@ -7551,7 +7551,7 @@ libvirt_virDomainSendKey(PyObject *self ATTRIBUTE_UNUSED,
int holdtime;
unsigned int flags;
int ret;
- size_t i;
+ ssize_t i;
unsigned int keycodes[VIR_DOMAIN_SEND_KEY_MAX_KEYS];
unsigned int nkeycodes;
@@ -7945,7 +7945,7 @@ libvirt_virNodeGetCPUMap(PyObject *self ATTRIBUTE_UNUSED,
unsigned char *cpumap = NULL;
unsigned int online = 0;
unsigned int flags;
- size_t i;
+ ssize_t i;
if (!PyArg_ParseTuple(args, (char *)"OI:virNodeGetCPUMap",
&pyobj_conn, &flags))
@@ -8002,7 +8002,7 @@ libvirt_virDomainCreateWithFiles(PyObject *self ATTRIBUTE_UNUSED,
unsigned int flags;
unsigned int nfiles;
int *files = NULL;
- size_t i;
+ ssize_t i;
if (!PyArg_ParseTuple(args, (char *)"OOI:virDomainCreateWithFiles",
&pyobj_domain, &pyobj_files, &flags))
@@ -8050,7 +8050,7 @@ libvirt_virDomainCreateXMLWithFiles(PyObject *self ATTRIBUTE_UNUSED,
unsigned int flags;
unsigned int nfiles;
int *files = NULL;
- size_t i;
+ ssize_t i;
if (!PyArg_ParseTuple(args, (char *)"OzOI:virDomainCreateXMLWithFiles",
&pyobj_conn, &xmlDesc, &pyobj_files, &flags))
@@ -8099,7 +8099,7 @@ libvirt_virDomainFSFreeze(PyObject *self ATTRIBUTE_UNUSED,
unsigned int flags;
unsigned int nmountpoints = 0;
char **mountpoints = NULL;
- size_t i = 0, j;
+ ssize_t i = 0, j;
if (!PyArg_ParseTuple(args, (char *)"OOI:virDomainFSFreeze",
&pyobj_domain, &pyobj_list, &flags))
@@ -8147,7 +8147,7 @@ libvirt_virDomainFSThaw(PyObject *self ATTRIBUTE_UNUSED,
unsigned int flags;
unsigned int nmountpoints = 0;
char **mountpoints = NULL;
- size_t i = 0, j;
+ ssize_t i = 0, j;
if (!PyArg_ParseTuple(args, (char *)"OOI:virDomainFSThaw",
&pyobj_domain, &pyobj_list, &flags))
@@ -8380,7 +8380,7 @@ libvirt_virNetworkGetDHCPLeases(PyObject *self ATTRIBUTE_UNUSED,
virNetworkDHCPLeasePtr *leases = NULL;
int leases_count;
char *mac = NULL;
- size_t i;
+ ssize_t i;
if (!PyArg_ParseTuple(args, (char *) "OzI:virNetworkGetDHCPLeases",
&pyobj_network, &mac, &flags))
@@ -8453,7 +8453,7 @@ convertDomainStatsRecord(virDomainStatsRecordPtr *records,
PyObject *py_record;
PyObject *py_record_stats = NULL;
virDomainPtr dom = NULL;
- size_t i;
+ ssize_t i;
if (!(py_retval = PyList_New(nrecords)))
return NULL;
@@ -8531,7 +8531,7 @@ libvirt_virDomainListGetStats(PyObject *self ATTRIBUTE_UNUSED,
virDomainPtr *doms = NULL;
int nrecords;
int ndoms;
- size_t i;
+ ssize_t i;
unsigned int flags;
unsigned int stats;
diff --git a/libvirt-utils.c b/libvirt-utils.c
index 727397d..b8ac5e9 100644
--- a/libvirt-utils.c
+++ b/libvirt-utils.c
@@ -221,7 +221,7 @@ getPyVirTypedParameter(const virTypedParameter *params,
int nparams)
{
PyObject *key, *val, *info;
- size_t i;
+ ssize_t i;
if ((info = PyDict_New()) == NULL)
return NULL;
@@ -295,7 +295,7 @@ setPyVirTypedParameter(PyObject *info,
#endif
virTypedParameterPtr temp = NULL, ret = NULL;
Py_ssize_t size;
- size_t i;
+ ssize_t i;
if ((size = PyDict_Size(info)) < 0)
return NULL;
@@ -412,7 +412,7 @@ virPyDictToTypedParamOne(virTypedParameterPtr *params,
PyObject *value)
{
int rv = -1, type = -1;
- size_t i;
+ ssize_t i;
for (i = 0; i < nhints; i++) {
if (STREQ(hints[i].name, keystr)) {
@@ -605,7 +605,7 @@ virPyCpumapConvert(int cpunum,
int *cpumaplen)
{
int tuple_size;
- size_t i;
+ ssize_t i;
*cpumapptr = NULL;
if (!PyTuple_Check(pycpumap)) {
diff --git a/typewrappers.c b/typewrappers.c
index a9561dd..01ee310 100644
--- a/typewrappers.c
+++ b/typewrappers.c
@@ -319,7 +319,7 @@ libvirt_ulonglongUnwrap(PyObject *obj,
PyErr_SetString(PyExc_TypeError, "an integer is required");
}
- if ((ullong_val == -1) && PyErr_Occurred())
+ if ((ullong_val == (unsigned long long)-1) && PyErr_Occurred())
return -1;
*val = ullong_val;
--
2.13.5
7 years, 2 months
[libvirt] [PATCH] qemu: monitor: fix graceful shutdown corner cases
by Nikolay Shirokovskiy
Patch aeda1b8c needs some enhancement.
1. Shutdown event is delivired on reboot too and we don't want
to set willhangup flag is this case.
2. There is a next race condition.
- EOF is delivered in event loop thread
- qemuMonitorSend is called on client behalf and waits for notification
on message response or monitor close
- EOF handler tries to accquire job condition and fail on timeout as
it is grabbed by the request above
Now qemuMonitorSend hangs.
Previously if qemuMonitorSend is called after EOF then it failed
immediately due to lastError is set. Now we need to check willhangup too.
---
Race is easy to trigger with patch [1]. One need to query domain
frequently enough in a loop and do a shutdown.
[1] Patch to trigger race condition.
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index b782451..4445f88 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -4742,6 +4742,9 @@ static void qemuProcessEventHandler(void *data, void *opaque)
VIR_DEBUG("vm=%p, event=%d", vm, processEvent->eventType);
+ if (processEvent->eventType == QEMU_PROCESS_EVENT_MONITOR_EOF)
+ sleep(3);
+
virObjectLock(vm);
switch (processEvent->eventType) {
src/qemu/qemu_monitor.c | 16 +++++++++++++++-
src/qemu/qemu_monitor.h | 2 ++
src/qemu/qemu_process.c | 1 +
3 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 19082d8..6270191 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -315,6 +315,15 @@ qemuMonitorEscapeNonPrintable(const char *text)
#endif
+void
+qemuMonitorShutdown(qemuMonitorPtr mon)
+{
+ virObjectLock(mon);
+ mon->willhangup = 1;
+ virObjectUnlock(mon);
+}
+
+
static void
qemuMonitorDispose(void *obj)
{
@@ -1055,6 +1064,12 @@ qemuMonitorSend(qemuMonitorPtr mon,
return -1;
}
+ if (mon->willhangup) {
+ virReportError(VIR_ERR_OPERATION_INVALID, "%s",
+ _("Domain is shutting down."));
+ return -1;
+ }
+
mon->msg = msg;
qemuMonitorUpdateWatch(mon);
@@ -1336,7 +1351,6 @@ qemuMonitorEmitShutdown(qemuMonitorPtr mon, virTristateBool guest)
{
int ret = -1;
VIR_DEBUG("mon=%p guest=%u", mon, guest);
- mon->willhangup = 1;
QEMU_MONITOR_CALLBACK(mon, ret, domainShutdown, mon->vm, guest);
return ret;
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index 9805a33..30533ef 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -303,6 +303,8 @@ void qemuMonitorUnregister(qemuMonitorPtr mon)
ATTRIBUTE_NONNULL(1);
void qemuMonitorClose(qemuMonitorPtr mon);
+void qemuMonitorShutdown(qemuMonitorPtr mon);
+
virErrorPtr qemuMonitorLastError(qemuMonitorPtr mon);
int qemuMonitorSetCapabilities(qemuMonitorPtr mon);
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index ab81d65..824be86 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -618,6 +618,7 @@ qemuProcessShutdownOrReboot(virQEMUDriverPtr driver,
virObjectUnref(vm);
}
} else {
+ qemuMonitorShutdown(priv->mon);
ignore_value(qemuProcessKill(vm, VIR_QEMU_PROCESS_KILL_NOWAIT));
}
}
--
1.8.3.1
7 years, 2 months
[libvirt] [PATCH python] Avoid implicit treatment of an arithmetic result as a boolean
by Daniel P. Berrange
Latest GCC versions are unhappy with us treating an integer
arithmetic result as a boolean:
libvirt-utils.c: In function ‘virReallocN’:
libvirt-utils.c:111:23: warning: ‘*’ in boolean context, suggest ‘&&’ instead [-Wint-in-bool-context]
if (!tmp && (size * count)) {
~~~~~~^~~~~~~~
Add an explicit comparison '!= 0' to keep it happy, since its
suggestion to use '&&' is nonsense.
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
libvirt-utils.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libvirt-utils.c b/libvirt-utils.c
index b8ac5e9..f7b4478 100644
--- a/libvirt-utils.c
+++ b/libvirt-utils.c
@@ -108,7 +108,7 @@ virReallocN(void *ptrptr,
return -1;
}
tmp = realloc(*(void**)ptrptr, size * count);
- if (!tmp && (size * count)) {
+ if (!tmp && ((size * count) != 0)) {
return -1;
}
*(void**)ptrptr = tmp;
--
2.13.5
7 years, 2 months