mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 13:45:38 +00:00
qemu: domain: Store and update 'fdsetindex' across libvirtd restarts
While 'add-fd' qmp command gives the possibility to find an unused fdset ID when hot-adding fdsets, such usage is extremely inconvenient. This patch allows us to track the used fdset id so that we can avoid the need to check results and thus employ simpler code flow when hot-adding devices which use FD passing. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
76709d4f48
commit
278c630d2a
@ -2372,6 +2372,8 @@ qemuDomainObjPrivateXMLFormat(virBuffer *buf,
|
|||||||
if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV))
|
if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV))
|
||||||
virBufferAsprintf(buf, "<nodename index='%llu'/>\n", priv->nodenameindex);
|
virBufferAsprintf(buf, "<nodename index='%llu'/>\n", priv->nodenameindex);
|
||||||
|
|
||||||
|
virBufferAsprintf(buf, "<fdset index='%u'/>\n", priv->fdsetindex);
|
||||||
|
|
||||||
if (priv->memPrealloc)
|
if (priv->memPrealloc)
|
||||||
virBufferAddLit(buf, "<memPrealloc/>\n");
|
virBufferAddLit(buf, "<memPrealloc/>\n");
|
||||||
|
|
||||||
@ -3106,6 +3108,9 @@ qemuDomainObjPrivateXMLParse(xmlXPathContextPtr ctxt,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (virXPathUInt("string(./fdset/@index)", ctxt, &priv->fdsetindex) == 0)
|
||||||
|
priv->fdsetindexParsed = true;
|
||||||
|
|
||||||
priv->memPrealloc = virXPathBoolean("boolean(./memPrealloc)", ctxt) == 1;
|
priv->memPrealloc = virXPathBoolean("boolean(./memPrealloc)", ctxt) == 1;
|
||||||
|
|
||||||
if (virXPathULongLong("string(./originalMemlock)",
|
if (virXPathULongLong("string(./originalMemlock)",
|
||||||
|
@ -204,8 +204,9 @@ struct _qemuDomainObjPrivate {
|
|||||||
/* counter for generating node names for qemu disks */
|
/* counter for generating node names for qemu disks */
|
||||||
unsigned long long nodenameindex;
|
unsigned long long nodenameindex;
|
||||||
|
|
||||||
/* counter for generating IDs of fdsets - only relevant during startup */
|
/* counter for generating IDs of fdsets */
|
||||||
unsigned int fdsetindex;
|
unsigned int fdsetindex;
|
||||||
|
bool fdsetindexParsed;
|
||||||
|
|
||||||
/* qemuProcessStartCPUs stores the reason for starting vCPUs here for the
|
/* qemuProcessStartCPUs stores the reason for starting vCPUs here for the
|
||||||
* RESUME event handler to use it */
|
* RESUME event handler to use it */
|
||||||
|
@ -2265,6 +2265,34 @@ qemuRefreshPRManagerState(virQEMUDriver *driver,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
qemuProcessRefreshFdsetIndex(virDomainObj *vm)
|
||||||
|
{
|
||||||
|
qemuDomainObjPrivate *priv = vm->privateData;
|
||||||
|
g_autoptr(qemuMonitorFdsets) fdsets = NULL;
|
||||||
|
size_t i;
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
/* if the previous index was in the status XML we don't need to update it */
|
||||||
|
if (priv->fdsetindexParsed)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
qemuDomainObjEnterMonitor(priv->driver, vm);
|
||||||
|
rc = qemuMonitorQueryFdsets(priv->mon, &fdsets);
|
||||||
|
qemuDomainObjExitMonitor(vm);
|
||||||
|
|
||||||
|
if (rc < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
for (i = 0; i < fdsets->nfdsets; i++) {
|
||||||
|
if (fdsets->fdsets[i].id >= priv->fdsetindex)
|
||||||
|
priv->fdsetindex = fdsets->fdsets[i].id + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
qemuRefreshRTC(virQEMUDriver *driver,
|
qemuRefreshRTC(virQEMUDriver *driver,
|
||||||
virDomainObj *vm)
|
virDomainObj *vm)
|
||||||
@ -8928,6 +8956,9 @@ qemuProcessReconnect(void *opaque)
|
|||||||
if (qemuRefreshPRManagerState(driver, obj) < 0)
|
if (qemuRefreshPRManagerState(driver, obj) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
if (qemuProcessRefreshFdsetIndex(obj) < 0)
|
||||||
|
goto error;
|
||||||
|
|
||||||
qemuProcessReconnectCheckMemAliasOrderMismatch(obj);
|
qemuProcessReconnectCheckMemAliasOrderMismatch(obj);
|
||||||
|
|
||||||
if (qemuConnectAgent(driver, obj) < 0)
|
if (qemuConnectAgent(driver, obj) < 0)
|
||||||
|
@ -234,6 +234,7 @@
|
|||||||
<chardevStdioLogd/>
|
<chardevStdioLogd/>
|
||||||
<allowReboot value='yes'/>
|
<allowReboot value='yes'/>
|
||||||
<nodename index='0'/>
|
<nodename index='0'/>
|
||||||
|
<fdset index='0'/>
|
||||||
<blockjobs active='yes'>
|
<blockjobs active='yes'>
|
||||||
<blockjob name='backup-vda-libvirt-3-format' type='backup' state='running' jobflags='0x0'>
|
<blockjob name='backup-vda-libvirt-3-format' type='backup' state='running' jobflags='0x0'>
|
||||||
<disk dst='vda'/>
|
<disk dst='vda'/>
|
||||||
|
@ -233,6 +233,7 @@
|
|||||||
<chardevStdioLogd/>
|
<chardevStdioLogd/>
|
||||||
<allowReboot value='yes'/>
|
<allowReboot value='yes'/>
|
||||||
<nodename index='0'/>
|
<nodename index='0'/>
|
||||||
|
<fdset index='0'/>
|
||||||
<blockjobs active='yes'>
|
<blockjobs active='yes'>
|
||||||
<blockjob name='broken-test' type='broken' state='ready' brokentype='commit'/>
|
<blockjob name='broken-test' type='broken' state='ready' brokentype='commit'/>
|
||||||
<blockjob name='commit-vdc-libvirt-9-format' type='commit' state='running' jobflags='0x0'>
|
<blockjob name='commit-vdc-libvirt-9-format' type='commit' state='running' jobflags='0x0'>
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
<libDir path='/tmp'/>
|
<libDir path='/tmp'/>
|
||||||
<channelTargetDir path='/tmp/channel'/>
|
<channelTargetDir path='/tmp/channel'/>
|
||||||
<allowReboot value='yes'/>
|
<allowReboot value='yes'/>
|
||||||
|
<fdset index='0'/>
|
||||||
<blockjobs active='yes'/>
|
<blockjobs active='yes'/>
|
||||||
<agentTimeout>-2</agentTimeout>
|
<agentTimeout>-2</agentTimeout>
|
||||||
<domain type='qemu' id='1'>
|
<domain type='qemu' id='1'>
|
||||||
|
@ -256,6 +256,7 @@
|
|||||||
<channelTargetDir path='/var/lib/libvirt/qemu/channel/target/domain-1-nest'/>
|
<channelTargetDir path='/var/lib/libvirt/qemu/channel/target/domain-1-nest'/>
|
||||||
<chardevStdioLogd/>
|
<chardevStdioLogd/>
|
||||||
<allowReboot value='yes'/>
|
<allowReboot value='yes'/>
|
||||||
|
<fdset index='0'/>
|
||||||
<blockjobs active='no'/>
|
<blockjobs active='no'/>
|
||||||
<agentTimeout>-2</agentTimeout>
|
<agentTimeout>-2</agentTimeout>
|
||||||
<domain type='kvm' id='1'>
|
<domain type='kvm' id='1'>
|
||||||
|
@ -343,6 +343,7 @@
|
|||||||
<rememberOwner/>
|
<rememberOwner/>
|
||||||
<allowReboot value='yes'/>
|
<allowReboot value='yes'/>
|
||||||
<nodename index='3'/>
|
<nodename index='3'/>
|
||||||
|
<fdset index='0'/>
|
||||||
<blockjobs active='yes'>
|
<blockjobs active='yes'>
|
||||||
<blockjob name='drive-virtio-disk0' type='copy' state='ready' jobflags='0x0'>
|
<blockjob name='drive-virtio-disk0' type='copy' state='ready' jobflags='0x0'>
|
||||||
<disk dst='vda'/>
|
<disk dst='vda'/>
|
||||||
|
@ -259,6 +259,7 @@
|
|||||||
<channelTargetDir path='/var/lib/libvirt/qemu/channel/target/domain-4-upstream'/>
|
<channelTargetDir path='/var/lib/libvirt/qemu/channel/target/domain-4-upstream'/>
|
||||||
<chardevStdioLogd/>
|
<chardevStdioLogd/>
|
||||||
<allowReboot value='yes'/>
|
<allowReboot value='yes'/>
|
||||||
|
<fdset index='0'/>
|
||||||
<blockjobs active='no'/>
|
<blockjobs active='no'/>
|
||||||
<agentTimeout>-2</agentTimeout>
|
<agentTimeout>-2</agentTimeout>
|
||||||
<domain type='kvm' id='4'>
|
<domain type='kvm' id='4'>
|
||||||
|
@ -288,6 +288,7 @@
|
|||||||
<channelTargetDir path='/var/lib/libvirt/qemu/channel/target/domain-3-upstream'/>
|
<channelTargetDir path='/var/lib/libvirt/qemu/channel/target/domain-3-upstream'/>
|
||||||
<chardevStdioLogd/>
|
<chardevStdioLogd/>
|
||||||
<allowReboot value='yes'/>
|
<allowReboot value='yes'/>
|
||||||
|
<fdset index='0'/>
|
||||||
<blockjobs active='no'/>
|
<blockjobs active='no'/>
|
||||||
<agentTimeout>-2</agentTimeout>
|
<agentTimeout>-2</agentTimeout>
|
||||||
<domain type='kvm' id='3'>
|
<domain type='kvm' id='3'>
|
||||||
|
@ -270,6 +270,7 @@
|
|||||||
<channelTargetDir path='/var/lib/libvirt/qemu/channel/target/domain-7-nest'/>
|
<channelTargetDir path='/var/lib/libvirt/qemu/channel/target/domain-7-nest'/>
|
||||||
<chardevStdioLogd/>
|
<chardevStdioLogd/>
|
||||||
<allowReboot value='yes'/>
|
<allowReboot value='yes'/>
|
||||||
|
<fdset index='0'/>
|
||||||
<blockjobs active='no'/>
|
<blockjobs active='no'/>
|
||||||
<agentTimeout>-2</agentTimeout>
|
<agentTimeout>-2</agentTimeout>
|
||||||
<domain type='kvm' id='7'>
|
<domain type='kvm' id='7'>
|
||||||
|
@ -261,6 +261,7 @@
|
|||||||
<chardevStdioLogd/>
|
<chardevStdioLogd/>
|
||||||
<allowReboot value='yes'/>
|
<allowReboot value='yes'/>
|
||||||
<nodename index='123'/>
|
<nodename index='123'/>
|
||||||
|
<fdset index='321'/>
|
||||||
<blockjobs active='no'/>
|
<blockjobs active='no'/>
|
||||||
<agentTimeout>-2</agentTimeout>
|
<agentTimeout>-2</agentTimeout>
|
||||||
<domain type='kvm' id='1'>
|
<domain type='kvm' id='1'>
|
||||||
|
@ -258,6 +258,7 @@
|
|||||||
<channelTargetDir path='/var/lib/libvirt/qemu/channel/target/domain-1-upstream'/>
|
<channelTargetDir path='/var/lib/libvirt/qemu/channel/target/domain-1-upstream'/>
|
||||||
<chardevStdioLogd/>
|
<chardevStdioLogd/>
|
||||||
<allowReboot value='yes'/>
|
<allowReboot value='yes'/>
|
||||||
|
<fdset index='0'/>
|
||||||
<blockjobs active='no'/>
|
<blockjobs active='no'/>
|
||||||
<agentTimeout>-2</agentTimeout>
|
<agentTimeout>-2</agentTimeout>
|
||||||
<domain type='kvm' id='1'>
|
<domain type='kvm' id='1'>
|
||||||
|
@ -308,6 +308,7 @@
|
|||||||
<libDir path='/tmp'/>
|
<libDir path='/tmp'/>
|
||||||
<channelTargetDir path='/tmp/channel'/>
|
<channelTargetDir path='/tmp/channel'/>
|
||||||
<allowReboot value='yes'/>
|
<allowReboot value='yes'/>
|
||||||
|
<fdset index='0'/>
|
||||||
<blockjobs active='no'/>
|
<blockjobs active='no'/>
|
||||||
<agentTimeout>-2</agentTimeout>
|
<agentTimeout>-2</agentTimeout>
|
||||||
<domain type='kvm' id='1729'>
|
<domain type='kvm' id='1729'>
|
||||||
|
Loading…
Reference in New Issue
Block a user