mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
conf: Add channel state for virtio channels to the XML
To track state of virtio channels this patch adds a new output-only attribute called 'state' to the <target> element of virtio channels. This will be later populated with the guest state of the channel.
This commit is contained in:
parent
e9a4506963
commit
24c25a68c2
@ -4911,7 +4911,7 @@ qemu-kvm -net nic,model=? /dev/null
|
|||||||
</channel>
|
</channel>
|
||||||
<channel type='unix'>
|
<channel type='unix'>
|
||||||
<source mode='bind' path='/var/lib/libvirt/qemu/f16x86_64.agent'/>
|
<source mode='bind' path='/var/lib/libvirt/qemu/f16x86_64.agent'/>
|
||||||
<target type='virtio' name='org.qemu.guest_agent.0'/>
|
<target type='virtio' name='org.qemu.guest_agent.0' state='connected'/>
|
||||||
</channel>
|
</channel>
|
||||||
<channel type='spicevmc'>
|
<channel type='spicevmc'>
|
||||||
<target type='virtio' name='com.redhat.spice.0'/>
|
<target type='virtio' name='com.redhat.spice.0'/>
|
||||||
@ -4950,7 +4950,12 @@ qemu-kvm -net nic,model=? /dev/null
|
|||||||
This is very useful in case of a qemu guest agent, where users don't
|
This is very useful in case of a qemu guest agent, where users don't
|
||||||
usually care about the source path since it's libvirt who talks to
|
usually care about the source path since it's libvirt who talks to
|
||||||
the guest agent. In case users want to utilize this feature, they should
|
the guest agent. In case users want to utilize this feature, they should
|
||||||
leave <code><source></code> element out.
|
leave <code><source></code> element out. <span class="since">Since
|
||||||
|
1.2.11</span> the active XML for a virtio channel may contain an optional
|
||||||
|
<code>state</code> attribute that reflects whether a process in the
|
||||||
|
guest is active on the channel. This is an output-only attribute.
|
||||||
|
Possible values for the <code>state</code> attribute are
|
||||||
|
<code>connected</code> and <code>disconnected</code>.
|
||||||
</dd>
|
</dd>
|
||||||
<dt><code>spicevmc</code></dt>
|
<dt><code>spicevmc</code></dt>
|
||||||
<dd>Paravirtualized SPICE channel. The domain must also have a
|
<dd>Paravirtualized SPICE channel. The domain must also have a
|
||||||
|
@ -3377,6 +3377,14 @@
|
|||||||
<optional>
|
<optional>
|
||||||
<attribute name="name"/>
|
<attribute name="name"/>
|
||||||
</optional>
|
</optional>
|
||||||
|
<optional>
|
||||||
|
<attribute name="state">
|
||||||
|
<choice>
|
||||||
|
<value>connected</value>
|
||||||
|
<value>disconnected</value>
|
||||||
|
</choice>
|
||||||
|
</attribute>
|
||||||
|
</optional>
|
||||||
</element>
|
</element>
|
||||||
</define>
|
</define>
|
||||||
<define name="channel">
|
<define name="channel">
|
||||||
|
@ -410,6 +410,11 @@ VIR_ENUM_IMPL(virDomainNetInterfaceLinkState, VIR_DOMAIN_NET_INTERFACE_LINK_STAT
|
|||||||
"up",
|
"up",
|
||||||
"down")
|
"down")
|
||||||
|
|
||||||
|
VIR_ENUM_IMPL(virDomainChrDeviceState, VIR_DOMAIN_CHR_DEVICE_STATE_LAST,
|
||||||
|
"default",
|
||||||
|
"connected",
|
||||||
|
"disconnected");
|
||||||
|
|
||||||
VIR_ENUM_IMPL(virDomainChrSerialTarget,
|
VIR_ENUM_IMPL(virDomainChrSerialTarget,
|
||||||
VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST,
|
VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_LAST,
|
||||||
"isa-serial",
|
"isa-serial",
|
||||||
@ -7857,13 +7862,15 @@ virDomainChrTargetTypeFromString(virDomainChrDefPtr def,
|
|||||||
|
|
||||||
static int
|
static int
|
||||||
virDomainChrDefParseTargetXML(virDomainChrDefPtr def,
|
virDomainChrDefParseTargetXML(virDomainChrDefPtr def,
|
||||||
xmlNodePtr cur)
|
xmlNodePtr cur,
|
||||||
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
unsigned int port;
|
unsigned int port;
|
||||||
char *targetType = virXMLPropString(cur, "type");
|
char *targetType = virXMLPropString(cur, "type");
|
||||||
char *addrStr = NULL;
|
char *addrStr = NULL;
|
||||||
char *portStr = NULL;
|
char *portStr = NULL;
|
||||||
|
char *stateStr = NULL;
|
||||||
|
|
||||||
if ((def->targetType =
|
if ((def->targetType =
|
||||||
virDomainChrTargetTypeFromString(def, def->deviceType,
|
virDomainChrTargetTypeFromString(def, def->deviceType,
|
||||||
@ -7920,6 +7927,20 @@ virDomainChrDefParseTargetXML(virDomainChrDefPtr def,
|
|||||||
|
|
||||||
case VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO:
|
case VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO:
|
||||||
def->target.name = virXMLPropString(cur, "name");
|
def->target.name = virXMLPropString(cur, "name");
|
||||||
|
|
||||||
|
if (!(flags & VIR_DOMAIN_XML_INACTIVE) &&
|
||||||
|
(stateStr = virXMLPropString(cur, "state"))) {
|
||||||
|
int tmp;
|
||||||
|
|
||||||
|
if ((tmp = virDomainChrDeviceStateTypeFromString(stateStr)) <= 0) {
|
||||||
|
virReportError(VIR_ERR_XML_ERROR,
|
||||||
|
_("invalid channel state value '%s'"),
|
||||||
|
stateStr);
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
|
def->state = tmp;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -7948,6 +7969,7 @@ virDomainChrDefParseTargetXML(virDomainChrDefPtr def,
|
|||||||
VIR_FREE(targetType);
|
VIR_FREE(targetType);
|
||||||
VIR_FREE(addrStr);
|
VIR_FREE(addrStr);
|
||||||
VIR_FREE(portStr);
|
VIR_FREE(portStr);
|
||||||
|
VIR_FREE(stateStr);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -8323,7 +8345,7 @@ virDomainChrDefParseXML(xmlXPathContextPtr ctxt,
|
|||||||
if (cur->type == XML_ELEMENT_NODE) {
|
if (cur->type == XML_ELEMENT_NODE) {
|
||||||
if (xmlStrEqual(cur->name, BAD_CAST "target")) {
|
if (xmlStrEqual(cur->name, BAD_CAST "target")) {
|
||||||
seenTarget = true;
|
seenTarget = true;
|
||||||
if (virDomainChrDefParseTargetXML(def, cur) < 0)
|
if (virDomainChrDefParseTargetXML(def, cur, flags) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -17520,13 +17542,18 @@ virDomainChrDefFormat(virBufferPtr buf,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO: {
|
case VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO:
|
||||||
if (def->target.name)
|
if (def->target.name)
|
||||||
virBufferEscapeString(buf, " name='%s'", def->target.name);
|
virBufferEscapeString(buf, " name='%s'", def->target.name);
|
||||||
|
|
||||||
|
if (def->state != VIR_DOMAIN_CHR_DEVICE_STATE_DEFAULT &&
|
||||||
|
!(flags & VIR_DOMAIN_XML_INACTIVE)) {
|
||||||
|
virBufferAsprintf(buf, " state='%s'",
|
||||||
|
virDomainChrDeviceStateTypeToString(def->state));
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
virBufferAddLit(buf, "/>\n");
|
virBufferAddLit(buf, "/>\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -990,6 +990,16 @@ struct _virDomainNetDef {
|
|||||||
* by libvirt, and cannot be used for a persistent network name. */
|
* by libvirt, and cannot be used for a persistent network name. */
|
||||||
# define VIR_NET_GENERATED_PREFIX "vnet"
|
# define VIR_NET_GENERATED_PREFIX "vnet"
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
VIR_DOMAIN_CHR_DEVICE_STATE_DEFAULT = 0,
|
||||||
|
VIR_DOMAIN_CHR_DEVICE_STATE_CONNECTED,
|
||||||
|
VIR_DOMAIN_CHR_DEVICE_STATE_DISCONNECTED,
|
||||||
|
|
||||||
|
VIR_DOMAIN_CHR_DEVICE_STATE_LAST
|
||||||
|
} virDomainChrDeviceState;
|
||||||
|
|
||||||
|
VIR_ENUM_DECL(virDomainChrDeviceState)
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL = 0,
|
VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL = 0,
|
||||||
VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL,
|
VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL,
|
||||||
@ -1113,6 +1123,8 @@ struct _virDomainChrDef {
|
|||||||
char *name; /* virtio */
|
char *name; /* virtio */
|
||||||
} target;
|
} target;
|
||||||
|
|
||||||
|
virDomainChrDeviceState state;
|
||||||
|
|
||||||
virDomainChrSourceDef source;
|
virDomainChrSourceDef source;
|
||||||
|
|
||||||
virDomainDeviceInfo info;
|
virDomainDeviceInfo info;
|
||||||
|
@ -0,0 +1,17 @@
|
|||||||
|
LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
|
||||||
|
/usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -nodefconfig -nodefaults \
|
||||||
|
-chardev socket,id=charmonitor,path=/tmp/test-monitor,server,nowait \
|
||||||
|
-mon chardev=charmonitor,id=monitor,mode=readline \
|
||||||
|
-no-acpi -boot c \
|
||||||
|
-device virtio-serial-pci,id=virtio-serial1,bus=pci.0,addr=0xa \
|
||||||
|
-usb -hda /dev/HostVG/QEMUGuest1 \
|
||||||
|
-chardev pty,id=charchannel0 \
|
||||||
|
-device virtserialport,bus=virtio-serial1.0,nr=3,chardev=charchannel0,\
|
||||||
|
id=channel0,name=org.linux-kvm.port.foo \
|
||||||
|
-chardev pty,id=charchannel1 \
|
||||||
|
-device virtserialport,bus=virtio-serial1.0,nr=4,chardev=charchannel1,\
|
||||||
|
id=channel1,name=org.linux-kvm.port.foo1 \
|
||||||
|
-chardev pty,id=charchannel2 \
|
||||||
|
-device virtserialport,bus=virtio-serial1.0,nr=5,chardev=charchannel2,\
|
||||||
|
id=channel2,name=org.linux-kvm.port.foo2 \
|
||||||
|
-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
|
42
tests/qemuxml2argvdata/qemuxml2argv-channel-virtio-state.xml
Normal file
42
tests/qemuxml2argvdata/qemuxml2argv-channel-virtio-state.xml
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
<domain type='qemu' id='2'>
|
||||||
|
<name>QEMUGuest1</name>
|
||||||
|
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
|
||||||
|
<memory unit='KiB'>219100</memory>
|
||||||
|
<currentMemory unit='KiB'>219100</currentMemory>
|
||||||
|
<vcpu placement='static' cpuset='1-4,8-20,525'>1</vcpu>
|
||||||
|
<os>
|
||||||
|
<type arch='i686' machine='pc'>hvm</type>
|
||||||
|
<boot dev='hd'/>
|
||||||
|
</os>
|
||||||
|
<clock offset='utc'/>
|
||||||
|
<on_poweroff>destroy</on_poweroff>
|
||||||
|
<on_reboot>restart</on_reboot>
|
||||||
|
<on_crash>destroy</on_crash>
|
||||||
|
<devices>
|
||||||
|
<emulator>/usr/bin/qemu</emulator>
|
||||||
|
<disk type='block' device='disk'>
|
||||||
|
<source dev='/dev/HostVG/QEMUGuest1'/>
|
||||||
|
<target dev='hda' bus='ide'/>
|
||||||
|
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
|
||||||
|
</disk>
|
||||||
|
<controller type='usb' index='0'/>
|
||||||
|
<controller type='ide' index='0'/>
|
||||||
|
<controller type='virtio-serial' index='1'>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='0' model='pci-root'/>
|
||||||
|
<channel type='pty'>
|
||||||
|
<target type='virtio' name='org.linux-kvm.port.foo' state='connected'/>
|
||||||
|
<address type='virtio-serial' controller='1' bus='0' port='3'/>
|
||||||
|
</channel>
|
||||||
|
<channel type='pty'>
|
||||||
|
<target type='virtio' name='org.linux-kvm.port.foo1' state='disconnected'/>
|
||||||
|
<address type='virtio-serial' controller='1' bus='0' port='4'/>
|
||||||
|
</channel>
|
||||||
|
<channel type='pty'>
|
||||||
|
<target type='virtio' name='org.linux-kvm.port.foo2'/>
|
||||||
|
<address type='virtio-serial' controller='1' bus='0' port='5'/>
|
||||||
|
</channel>
|
||||||
|
<memballoon model='virtio'/>
|
||||||
|
</devices>
|
||||||
|
</domain>
|
@ -1070,6 +1070,8 @@ mymain(void)
|
|||||||
QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
|
QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
|
||||||
DO_TEST("channel-virtio",
|
DO_TEST("channel-virtio",
|
||||||
QEMU_CAPS_DEVICE, QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG);
|
QEMU_CAPS_DEVICE, QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG);
|
||||||
|
DO_TEST("channel-virtio-state",
|
||||||
|
QEMU_CAPS_DEVICE, QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG);
|
||||||
DO_TEST("channel-virtio-auto",
|
DO_TEST("channel-virtio-auto",
|
||||||
QEMU_CAPS_DEVICE, QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG);
|
QEMU_CAPS_DEVICE, QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG);
|
||||||
DO_TEST("console-virtio",
|
DO_TEST("console-virtio",
|
||||||
|
@ -0,0 +1,43 @@
|
|||||||
|
<domain type='qemu' id='2'>
|
||||||
|
<name>QEMUGuest1</name>
|
||||||
|
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
|
||||||
|
<memory unit='KiB'>219100</memory>
|
||||||
|
<currentMemory unit='KiB'>219100</currentMemory>
|
||||||
|
<vcpu placement='static' cpuset='1-4,8-20,525'>1</vcpu>
|
||||||
|
<os>
|
||||||
|
<type arch='i686' machine='pc'>hvm</type>
|
||||||
|
<boot dev='hd'/>
|
||||||
|
</os>
|
||||||
|
<clock offset='utc'/>
|
||||||
|
<on_poweroff>destroy</on_poweroff>
|
||||||
|
<on_reboot>restart</on_reboot>
|
||||||
|
<on_crash>destroy</on_crash>
|
||||||
|
<devices>
|
||||||
|
<emulator>/usr/bin/qemu</emulator>
|
||||||
|
<disk type='block' device='disk'>
|
||||||
|
<source dev='/dev/HostVG/QEMUGuest1'/>
|
||||||
|
<backingStore/>
|
||||||
|
<target dev='hda' bus='ide'/>
|
||||||
|
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
|
||||||
|
</disk>
|
||||||
|
<controller type='usb' index='0'/>
|
||||||
|
<controller type='ide' index='0'/>
|
||||||
|
<controller type='virtio-serial' index='1'>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='0' model='pci-root'/>
|
||||||
|
<channel type='pty'>
|
||||||
|
<target type='virtio' name='org.linux-kvm.port.foo' state='connected'/>
|
||||||
|
<address type='virtio-serial' controller='1' bus='0' port='3'/>
|
||||||
|
</channel>
|
||||||
|
<channel type='pty'>
|
||||||
|
<target type='virtio' name='org.linux-kvm.port.foo1' state='disconnected'/>
|
||||||
|
<address type='virtio-serial' controller='1' bus='0' port='4'/>
|
||||||
|
</channel>
|
||||||
|
<channel type='pty'>
|
||||||
|
<target type='virtio' name='org.linux-kvm.port.foo2'/>
|
||||||
|
<address type='virtio-serial' controller='1' bus='0' port='5'/>
|
||||||
|
</channel>
|
||||||
|
<memballoon model='virtio'/>
|
||||||
|
</devices>
|
||||||
|
</domain>
|
@ -0,0 +1,42 @@
|
|||||||
|
<domain type='qemu'>
|
||||||
|
<name>QEMUGuest1</name>
|
||||||
|
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
|
||||||
|
<memory unit='KiB'>219100</memory>
|
||||||
|
<currentMemory unit='KiB'>219100</currentMemory>
|
||||||
|
<vcpu placement='static' cpuset='1-4,8-20,525'>1</vcpu>
|
||||||
|
<os>
|
||||||
|
<type arch='i686' machine='pc'>hvm</type>
|
||||||
|
<boot dev='hd'/>
|
||||||
|
</os>
|
||||||
|
<clock offset='utc'/>
|
||||||
|
<on_poweroff>destroy</on_poweroff>
|
||||||
|
<on_reboot>restart</on_reboot>
|
||||||
|
<on_crash>destroy</on_crash>
|
||||||
|
<devices>
|
||||||
|
<emulator>/usr/bin/qemu</emulator>
|
||||||
|
<disk type='block' device='disk'>
|
||||||
|
<source dev='/dev/HostVG/QEMUGuest1'/>
|
||||||
|
<target dev='hda' bus='ide'/>
|
||||||
|
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
|
||||||
|
</disk>
|
||||||
|
<controller type='usb' index='0'/>
|
||||||
|
<controller type='ide' index='0'/>
|
||||||
|
<controller type='virtio-serial' index='1'>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='0' model='pci-root'/>
|
||||||
|
<channel type='pty'>
|
||||||
|
<target type='virtio' name='org.linux-kvm.port.foo'/>
|
||||||
|
<address type='virtio-serial' controller='1' bus='0' port='3'/>
|
||||||
|
</channel>
|
||||||
|
<channel type='pty'>
|
||||||
|
<target type='virtio' name='org.linux-kvm.port.foo1'/>
|
||||||
|
<address type='virtio-serial' controller='1' bus='0' port='4'/>
|
||||||
|
</channel>
|
||||||
|
<channel type='pty'>
|
||||||
|
<target type='virtio' name='org.linux-kvm.port.foo2'/>
|
||||||
|
<address type='virtio-serial' controller='1' bus='0' port='5'/>
|
||||||
|
</channel>
|
||||||
|
<memballoon model='virtio'/>
|
||||||
|
</devices>
|
||||||
|
</domain>
|
@ -288,6 +288,7 @@ mymain(void)
|
|||||||
DO_TEST("console-virtio-many");
|
DO_TEST("console-virtio-many");
|
||||||
DO_TEST("channel-guestfwd");
|
DO_TEST("channel-guestfwd");
|
||||||
DO_TEST("channel-virtio");
|
DO_TEST("channel-virtio");
|
||||||
|
DO_TEST_DIFFERENT("channel-virtio-state");
|
||||||
|
|
||||||
DO_TEST("hostdev-usb-address");
|
DO_TEST("hostdev-usb-address");
|
||||||
DO_TEST("hostdev-pci-address");
|
DO_TEST("hostdev-pci-address");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user