[libvirt] [libvirt-glib 1/6] Set correct target node attribute for domain interface
by Zeeshan Ali (Khattak)
From: "Zeeshan Ali (Khattak)" <zeeshanak(a)gnome.org>
gvir_config_domain_interface_set_ifname() should be setting 'dev'
attribute under 'target', not 'device'.
---
libvirt-gconfig/libvirt-gconfig-domain-interface.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-interface.c b/libvirt-gconfig/libvirt-gconfig-domain-interface.c
index 85cc194..eab4313 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-interface.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain-interface.c
@@ -57,7 +57,7 @@ void gvir_config_domain_interface_set_ifname(GVirConfigDomainInterface *interfac
g_return_if_fail(GVIR_CONFIG_IS_DOMAIN_INTERFACE(interface));
gvir_config_object_replace_child_with_attribute(GVIR_CONFIG_OBJECT(interface),
- "target", "device", ifname);
+ "target", "dev", ifname);
}
void gvir_config_domain_interface_set_link_state(GVirConfigDomainInterface *interface,
--
1.7.7.6
12 years, 9 months
[libvirt] [Patch]: spice agent-mouse support.[v2]
by Zhou Peng
Signed-off-by: Zhou Peng <zhoupeng(a)nfs.iscas.ac.cn>
spice agent-mouse support
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 6fcca94..d6d2f36 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -2742,7 +2742,10 @@ qemu-kvm -net nic,model=? /dev/null
while <code>tlsPort</code> gives an alternative secure
port number. The <code>autoport</code> attribute is the
new preferred syntax for indicating autoallocation of
- both port numbers. The <code>listen</code> attribute is
+ both port numbers. The <code>agentmouse</code> attribute
+ is used to specify whether spice agent is used for client
+ mouse mode(default is on).
+ The <code>listen</code> attribute is
an IP address for the server to listen
on. The <code>passwd</code> attribute provides a SPICE
password in clear text. The <code>keymap</code>
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 3908733..97b40d7 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -1650,6 +1650,14 @@
</attribute>
</optional>
<optional>
+ <attribute name="agentmouse">
+ <choice>
+ <value>on</value>
+ <value>off</value>
+ </choice>
+ </attribute>
+ </optional>
+ <optional>
<attribute name="listen">
<ref name="addrIPorName"/>
</attribute>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index f9654f1..a5f88ec 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -460,6 +460,12 @@ VIR_ENUM_IMPL(virDomainGraphicsSpicePlaybackCompression,
"on",
"off");
+VIR_ENUM_IMPL(virDomainGraphicsSpiceAgentMouse,
+ VIR_DOMAIN_GRAPHICS_SPICE_AGENT_MOUSE_LAST,
+ "default",
+ "on",
+ "off");
+
VIR_ENUM_IMPL(virDomainGraphicsSpiceStreamingMode,
VIR_DOMAIN_GRAPHICS_SPICE_STREAMING_MODE_LAST,
"default",
@@ -5288,6 +5294,7 @@ virDomainGraphicsDefParseXML(xmlNodePtr node,
int nListens;
xmlNodePtr *listenNodes = NULL;
char *listenAddr = NULL;
+ char *agentmouse = NULL;
xmlNodePtr save = ctxt->node;
if (VIR_ALLOC(def) < 0) {
@@ -5543,6 +5550,20 @@ virDomainGraphicsDefParseXML(xmlNodePtr node,
VIR_FREE(autoport);
}
+ if ((agentmouse = virXMLPropString(node, "agentmouse")) != NULL) {
+ int am;
+ if ((am = virDomainGraphicsSpiceAgentMouseTypeFromString(
+ agentmouse)) <= 0) {
+ virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("unknown spice agentmouse mode '%s'"),
+ agentmouse);
+ VIR_FREE(agentmouse);
+ goto error;
+ }
+ VIR_FREE(agentmouse);
+ def->data.spice.agentmouse = am;
+ }
+
def->data.spice.keymap = virXMLPropString(node, "keymap");
if (virDomainGraphicsAuthDefParseXML(node, &def->data.spice.auth,
@@ -11255,6 +11276,8 @@ virDomainGraphicsDefFormat(virBufferPtr buf,
{
const char *type = virDomainGraphicsTypeToString(def->type);
const char *listenAddr = NULL;
+ const char *agentmouse = virDomainGraphicsSpiceAgentMouseTypeToString(
+ def->data.spice.agentmouse);
int children = 0;
int i;
@@ -11364,6 +11387,9 @@ virDomainGraphicsDefFormat(virBufferPtr buf,
if (listenAddr)
virBufferAsprintf(buf, " listen='%s'", listenAddr);
+ if (def->data.spice.agentmouse)
+ virBufferEscapeString(buf, " agentmouse='%s'", agentmouse);
+
if (def->data.spice.keymap)
virBufferEscapeString(buf, " keymap='%s'",
def->data.spice.keymap);
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 596be4d..bdc9a45 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1003,6 +1003,14 @@ enum virDomainGraphicsSpicePlaybackCompression {
VIR_DOMAIN_GRAPHICS_SPICE_PLAYBACK_COMPRESSION_LAST
};
+enum virDomainGraphicsSpiceAgentMouse {
+ VIR_DOMAIN_GRAPHICS_SPICE_AGENT_MOUSE_DEFAULT = 0,
+ VIR_DOMAIN_GRAPHICS_SPICE_AGENT_MOUSE_ON,
+ VIR_DOMAIN_GRAPHICS_SPICE_AGENT_MOUSE_OFF,
+
+ VIR_DOMAIN_GRAPHICS_SPICE_AGENT_MOUSE_LAST
+};
+
enum virDomainGraphicsSpiceStreamingMode {
VIR_DOMAIN_GRAPHICS_SPICE_STREAMING_MODE_DEFAULT = 0,
VIR_DOMAIN_GRAPHICS_SPICE_STREAMING_MODE_FILTER,
@@ -1072,6 +1080,7 @@ struct _virDomainGraphicsDef {
struct {
int port;
int tlsPort;
+ int agentmouse;
char *keymap;
virDomainGraphicsAuthDef auth;
unsigned int autoport :1;
@@ -2061,6 +2070,7 @@ VIR_ENUM_DECL(virDomainGraphicsSpiceZlibCompression)
VIR_ENUM_DECL(virDomainGraphicsSpicePlaybackCompression)
VIR_ENUM_DECL(virDomainGraphicsSpiceStreamingMode)
VIR_ENUM_DECL(virDomainGraphicsSpiceClipboardCopypaste)
+VIR_ENUM_DECL(virDomainGraphicsSpiceAgentMouse)
VIR_ENUM_DECL(virDomainNumatuneMemMode)
VIR_ENUM_DECL(virDomainSnapshotState)
/* from libvirt.h */
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index b9baf9a..ba8523a 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -252,6 +252,8 @@ virDomainChrDefFree;
virDomainChrDefNew;
virDomainChrSourceDefCopy;
virDomainChrSourceDefFree;
+virDomainGraphicsSpiceAgentMouseTypeFromString;
+virDomainGraphicsSpiceAgentMouseTypeToString;
virDomainChrSpicevmcTypeFromString;
virDomainChrSpicevmcTypeToString;
virDomainChrTcpProtocolTypeFromString;
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 64a4546..2bbc077 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -154,6 +154,7 @@ VIR_ENUM_IMPL(qemuCaps, QEMU_CAPS_LAST,
"drive-iotune", /* 85 */
"system_wakeup",
"scsi-disk.channel",
+ "spice-agent-mouse",
);
struct qemu_feature_flags {
@@ -1049,8 +1050,13 @@ qemuCapsComputeCmdFlags(const char *help,
if ((p = strstr(p, "|none")) && p < nl)
qemuCapsSet(flags, QEMU_CAPS_VGA_NONE);
}
- if (strstr(help, "-spice"))
+ if (strstr(help, "-spice")) {
qemuCapsSet(flags, QEMU_CAPS_SPICE);
+
+ /* If SPICE is avail, agent-mouse option will be avail for qemu,
+ * although 'qemu --help' doesn't show it. */
+ qemuCapsSet(flags, QEMU_CAPS_SPICE_AGENTMOUSE);
+ }
if (strstr(help, "boot=on"))
qemuCapsSet(flags, QEMU_CAPS_DRIVE_BOOT);
if (strstr(help, "serial=s"))
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index db584ce..2e9faba 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -122,6 +122,7 @@ enum qemuCapsFlags {
QEMU_CAPS_DRIVE_IOTUNE = 85, /* -drive bps= and friends */
QEMU_CAPS_WAKEUP = 86, /* system_wakeup monitor command */
QEMU_CAPS_SCSI_DISK_CHANNEL = 87, /* Is scsi-disk.channel available? */
+ QEMU_CAPS_SPICE_AGENTMOUSE = 88, /* -spice agent-mouse=on|off */
QEMU_CAPS_LAST, /* this must always be the last item */
};
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 01adf0d..9d5a9ad 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -5391,6 +5391,18 @@ qemuBuildCommandLine(virConnectPtr conn,
VIR_FREE(netAddr);
+ const char *agentmouse = virDomainGraphicsSpiceAgentMouseTypeToString(
+ def->graphics[0]->data.spice.agentmouse);
+ if (def->graphics[0]->data.spice.agentmouse) {
+ if (qemuCapsGet(qemuCaps, QEMU_CAPS_SPICE_AGENTMOUSE))
+ virBufferAsprintf(&opt, ",agent-mouse=%s", agentmouse);
+ else {
+ qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("spice agent-mouse is not supported
with this QEMU"));
+ goto error;
+ }
+ }
+
/* In the password case we set it via monitor command, to avoid
* making it visible on CLI, so there's no use of password=XXX
* in this bit of the code */
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-spice-agentmouse.args
b/tests/qemuxml2argvdata/qemuxml2argv-spice-agentmouse.args
new file mode 100644
index 0000000..46be6d8
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-spice-agentmouse.args
@@ -0,0 +1,19 @@
+LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test
QEMU_AUDIO_DRV=spice \
+/usr/bin/qemu -S -M pc -m 214 -smp 1 -nodefconfig -nodefaults \
+-monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -device \
+virtio-serial-pci,id=virtio-serial1,bus=pci.0,addr=0xa -hda \
+/dev/HostVG/QEMUGuest1 -chardev spicevmc,id=charchannel0,name=vdagent -device \
+virtserialport,bus=virtio-serial1.0,nr=3,chardev=charchannel0,id=channel0\
+,name=com.redhat.spice.0 -usb -spice port=5903,tls-port=5904,addr=127.0.0.1,\
+agent-mouse=off,x509-dir=/etc/pki/libvirt-spice,tls-channel=main -device \
+virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
+
+#LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test
QEMU_AUDIO_DRV=spice \
+/usr/bin/qemu -S -M pc -m 214 -smp 1 -nodefconfig -nodefaults \
+-monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -device \
+virtio-serial-pci,id=virtio-serial1,bus=pci.0,addr=0xa -hda \
+/dev/HostVG/QEMUGuest1 -chardev spicevmc,id=charchannel0,name=vdagent -device \
+virtserialport,bus=virtio-serial1.0,nr=3,chardev=charchannel0,id=channel0\
+,name=com.redhat.spice.0 -usb -spice port=5903,tls-port=5904,addr=127.0.0.1,\
+agent-mouse=on,x509-dir=/etc/pki/libvirt-spice,tls-channel=main -device \
+virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-spice-agentmouse.xml
b/tests/qemuxml2argvdata/qemuxml2argv-spice-agentmouse.xml
new file mode 100644
index 0000000..4b36c2c
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-spice-agentmouse.xml
@@ -0,0 +1,38 @@
+<domain type='qemu'>
+ <name>QEMUGuest1</name>
+ <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+ <memory>219136</memory>
+ <vcpu 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>
+<!--
+ <graphics type='spice' port='5903' tlsPort='5904' autoport='no'
listen='127.0.0.1' agentmouse='on'>
+-->
+ <graphics type='spice' port='5903' tlsPort='5904' autoport='no'
listen='127.0.0.1' agentmouse='off'>
+ <channel name='main' mode='secure'/>
+ </graphics>
+ <channel type='spicevmc'>
+ <target type='virtio' name='com.redhat.spice.0'/>
+ <address type='virtio-serial' controller='1' bus='0' port='3'/>
+ </channel>
+ <memballoon model='virtio'/>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index fcffc27..9a27333 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -514,6 +514,10 @@ mymain(void)
DO_TEST("graphics-spice-compression", false,
QEMU_CAPS_VGA, QEMU_CAPS_VGA_QXL,
QEMU_CAPS_DEVICE, QEMU_CAPS_SPICE);
+ DO_TEST("graphics-spice-agentmouse", false,
+ QEMU_CAPS_VGA, QEMU_CAPS_VGA_QXL,
+ QEMU_CAPS_DEVICE, QEMU_CAPS_SPICE,
+ QEMU_CAPS_SPICE_AGENTMOUSE);
DO_TEST("graphics-spice-timeout", false,
QEMU_CAPS_DRIVE,
QEMU_CAPS_VGA, QEMU_CAPS_VGA_QXL,
--
Zhou Peng
12 years, 9 months
[libvirt] [PATCH v5 0/2] util: Add netlink event handling code
by D. Herrendoerfer
From: "D. Herrendoerfer" <d.herrendoerfer(a)herrendoerfer.name>
This is the updated netlink event code based upon the updated
virnetlink.[ch] files.
Also the related code to virnetdevmacvlan is included as well
as the related changes to the setup code.
D. Herrendoerfer (2):
util: Add netlink event handling to virnetlink.c
Add de-association handling to macvlan code
daemon/libvirtd.c | 8 +
src/libvirt_private.syms | 6 +
src/qemu/qemu_migration.c | 2 +-
src/util/virnetdevmacvlan.c | 315 +++++++++++++++++++++++++++-
src/util/virnetdevvportprofile.c | 33 ++-
src/util/virnetdevvportprofile.h | 3 +-
src/util/virnetlink.c | 438 +++++++++++++++++++++++++++++++++++++-
src/util/virnetlink.h | 29 +++
8 files changed, 815 insertions(+), 19 deletions(-)
--
1.7.7.5
12 years, 9 months
[libvirt] [libvirt-glib] RFC: Empty statistics for user-mode interfaces
by Zeeshan Ali (Khattak)
From: "Zeeshan Ali (Khattak)" <zeeshanak(a)gnome.org>
One of the limitations of user-mode networking of libvirt is that you
can't get statistics for it (not yet, at least). Instead of erroring-out
in that case, simply return empty statistics result and spit a debug
message.
I will merge this into my 'Remove now redundant 'path' property' patch
once someone tells me that this makes sense. :)
---
libvirt-gobject/libvirt-gobject-domain-interface.c | 10 +++++++++-
1 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/libvirt-gobject/libvirt-gobject-domain-interface.c b/libvirt-gobject/libvirt-gobject-domain-interface.c
index 0a9bde0..4436466 100644
--- a/libvirt-gobject/libvirt-gobject-domain-interface.c
+++ b/libvirt-gobject/libvirt-gobject-domain-interface.c
@@ -94,7 +94,11 @@ static gchar *gvir_domain_interface_get_path(GVirDomainInterface *self)
gchar *path = NULL;
config = gvir_domain_device_get_config(GVIR_DOMAIN_DEVICE(self));
- path = gvir_config_domain_interface_get_ifname(GVIR_CONFIG_DOMAIN_INTERFACE (config));
+ if (GVIR_CONFIG_IS_DOMAIN_INTERFACE_USER(self))
+ /* FIXME: One of the limitations of user-mode networking of libvirt */
+ g_debug("Statistics gathering for user-mode network not yet supported");
+ else
+ path = gvir_config_domain_interface_get_ifname(GVIR_CONFIG_DOMAIN_INTERFACE (config));
g_object_unref (config);
@@ -123,6 +127,10 @@ GVirDomainInterfaceStats *gvir_domain_interface_get_stats(GVirDomainInterface *s
handle = gvir_domain_device_get_domain_handle(GVIR_DOMAIN_DEVICE(self));
path = gvir_domain_interface_get_path (self);
+ if (path == NULL) {
+ ret = g_slice_new0(GVirDomainInterfaceStats);
+ goto end;
+ }
if (virDomainInterfaceStats(handle, path, &stats, sizeof (stats)) < 0) {
gvir_set_error_literal(err, GVIR_DOMAIN_INTERFACE_ERROR,
--
1.7.7.6
12 years, 9 months
[libvirt] Important, switch of server for libvirt.org
by Daniel Veillard
I learned yesterday that the lab hosting libvirt.org would
have power cut off for the week-end due to electical maintainance.
I took the opportunity to switch the server to a new box,
and just made the switch to the DNS, it may take up to 8 hours
to propagate though.
I cut ssh access to the old server 194.199.20.115 and reactivated
all services on the new box 176.31.99.103 . For read only access
nobody should notice the switch, only commiters should notice that
and hopefully they are all sleeping right now :-)
Grab me on IRC or by email if you notice somethings which doesn't
work right (the search is not setup yet and I need to reaactivate
various crons, but nearly everything should just work (TM))
Daniel
--
Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/
daniel(a)veillard.com | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library http://libvirt.org/
12 years, 9 months
[libvirt] [libvirt-glib 1/6] Getters for GVirConfigDomainInterface attributes
by Zeeshan Ali (Khattak)
From: "Zeeshan Ali (Khattak)" <zeeshanak(a)gnome.org>
---
libvirt-gconfig/libvirt-gconfig-domain-interface.c | 35 ++++++++++++++++++++
libvirt-gconfig/libvirt-gconfig-domain-interface.h | 4 ++
libvirt-gconfig/libvirt-gconfig.sym | 4 ++
3 files changed, 43 insertions(+), 0 deletions(-)
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-interface.c b/libvirt-gconfig/libvirt-gconfig-domain-interface.c
index 85cc194..61d35bd 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-interface.c
+++ b/libvirt-gconfig/libvirt-gconfig-domain-interface.c
@@ -96,6 +96,41 @@ void gvir_config_domain_interface_set_model(GVirConfigDomainInterface *interface
"model", "type", model);
}
+const char *gvir_config_domain_interface_get_ifname(GVirConfigDomainInterface *interface)
+{
+ g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_INTERFACE(interface), NULL);
+
+ return gvir_config_object_get_attribute(GVIR_CONFIG_OBJECT(interface),
+ "target", "device");
+}
+
+GVirConfigDomainInterfaceLinkState gvir_config_domain_interface_get_link_state(GVirConfigDomainInterface *interface)
+{
+ g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_INTERFACE(interface),
+ GVIR_CONFIG_DOMAIN_INTERFACE_LINK_STATE_DEFAULT);
+
+ return gvir_config_object_get_attribute_genum(GVIR_CONFIG_OBJECT(interface),
+ "link", "state",
+ GVIR_CONFIG_TYPE_DOMAIN_INTERFACE_LINK_STATE,
+ GVIR_CONFIG_DOMAIN_INTERFACE_LINK_STATE_DEFAULT);
+}
+
+const char *gvir_config_domain_interface_get_mac(GVirConfigDomainInterface *interface)
+{
+ g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_INTERFACE(interface), NULL);
+
+ return gvir_config_object_get_attribute(GVIR_CONFIG_OBJECT(interface),
+ "mac", "address");
+}
+
+const char *gvir_config_domain_interface_get_model(GVirConfigDomainInterface *interface)
+{
+ g_return_val_if_fail(GVIR_CONFIG_IS_DOMAIN_INTERFACE(interface), NULL);
+
+ return gvir_config_object_get_attribute(GVIR_CONFIG_OBJECT(interface),
+ "model", "type");
+}
+
G_GNUC_INTERNAL GVirConfigDomainDevice *
gvir_config_domain_interface_new_from_tree(GVirConfigXmlDoc *doc,
xmlNodePtr tree)
diff --git a/libvirt-gconfig/libvirt-gconfig-domain-interface.h b/libvirt-gconfig/libvirt-gconfig-domain-interface.h
index 6e802fb..c8c4fb3 100644
--- a/libvirt-gconfig/libvirt-gconfig-domain-interface.h
+++ b/libvirt-gconfig/libvirt-gconfig-domain-interface.h
@@ -72,6 +72,10 @@ void gvir_config_domain_interface_set_mac(GVirConfigDomainInterface *interface,
const char *mac_address);
void gvir_config_domain_interface_set_model(GVirConfigDomainInterface *interface,
const char *model);
+const char *gvir_config_domain_interface_get_ifname(GVirConfigDomainInterface *interface);
+GVirConfigDomainInterfaceLinkState gvir_config_domain_interface_get_link_state(GVirConfigDomainInterface *interface);
+const char *gvir_config_domain_interface_get_mac(GVirConfigDomainInterface *interface);
+const char *gvir_config_domain_interface_get_model(GVirConfigDomainInterface *interface);
G_END_DECLS
diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym
index 96ce58f..f91b8b0 100644
--- a/libvirt-gconfig/libvirt-gconfig.sym
+++ b/libvirt-gconfig/libvirt-gconfig.sym
@@ -145,6 +145,10 @@ LIBVIRT_GCONFIG_0.0.4 {
gvir_config_domain_interface_set_link_state;
gvir_config_domain_interface_set_mac;
gvir_config_domain_interface_set_model;
+ gvir_config_domain_interface_get_ifname;
+ gvir_config_domain_interface_get_link_state;
+ gvir_config_domain_interface_get_mac;
+ gvir_config_domain_interface_get_model;
gvir_config_domain_interface_bridge_get_type;
gvir_config_domain_interface_bridge_new;
--
1.7.7.6
12 years, 9 months
[libvirt] [libvirt-glib] Remove now redundant 'path' property
by Zeeshan Ali (Khattak)
From: "Zeeshan Ali (Khattak)" <zeeshanak(a)gnome.org>
Remove now redundant 'path' property from GVirDomainDevice subclasses.
These classes now have access to their configurations, from which they
can easily get the path (among other properties) internally.
---
libvirt-gobject/libvirt-gobject-domain-disk.c | 84 ++++---------------
libvirt-gobject/libvirt-gobject-domain-interface.c | 85 ++++---------------
2 files changed, 36 insertions(+), 133 deletions(-)
diff --git a/libvirt-gobject/libvirt-gobject-domain-disk.c b/libvirt-gobject/libvirt-gobject-domain-disk.c
index fb7672e..0a1493a 100644
--- a/libvirt-gobject/libvirt-gobject-domain-disk.c
+++ b/libvirt-gobject/libvirt-gobject-domain-disk.c
@@ -36,73 +36,25 @@
struct _GVirDomainDiskPrivate
{
- gchar *path;
+ gboolean unused;
};
G_DEFINE_TYPE(GVirDomainDisk, gvir_domain_disk, GVIR_TYPE_DOMAIN_DEVICE);
-enum {
- PROP_0,
- PROP_PATH,
-};
-
#define GVIR_DOMAIN_DISK_ERROR gvir_domain_disk_error_quark()
-
static GQuark
gvir_domain_disk_error_quark(void)
{
return g_quark_from_static_string("gvir-domain-disk");
}
-static void gvir_domain_disk_get_property(GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- GVirDomainDisk *self = GVIR_DOMAIN_DISK(object);
- GVirDomainDiskPrivate *priv = self->priv;
-
- switch (prop_id) {
- case PROP_PATH:
- g_value_set_string(value, priv->path);
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
- }
-}
-
-
-static void gvir_domain_disk_set_property(GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- GVirDomainDisk *self = GVIR_DOMAIN_DISK(object);
- GVirDomainDiskPrivate *priv = self->priv;
-
- switch (prop_id) {
- case PROP_PATH:
- g_free(priv->path);
- priv->path = g_value_dup_string(value);
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
- }
-}
-
-
static void gvir_domain_disk_finalize(GObject *object)
{
GVirDomainDisk *self = GVIR_DOMAIN_DISK(object);
- GVirDomainDiskPrivate *priv = self->priv;
g_debug("Finalize GVirDomainDisk=%p", self);
- g_free(priv->path);
-
G_OBJECT_CLASS(gvir_domain_disk_parent_class)->finalize(object);
}
@@ -111,19 +63,6 @@ static void gvir_domain_disk_class_init(GVirDomainDiskClass *klass)
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = gvir_domain_disk_finalize;
- object_class->get_property = gvir_domain_disk_get_property;
- object_class->set_property = gvir_domain_disk_set_property;
-
- g_object_class_install_property(object_class,
- PROP_PATH,
- g_param_spec_string("path",
- "Path",
- "The disk path",
- NULL,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_STRINGS));
-
g_type_class_add_private(klass, sizeof(GVirDomainDiskPrivate));
}
@@ -151,6 +90,15 @@ gvir_domain_disk_stats_free(GVirDomainDiskStats *stats)
G_DEFINE_BOXED_TYPE(GVirDomainDiskStats, gvir_domain_disk_stats,
gvir_domain_disk_stats_copy, gvir_domain_disk_stats_free)
+static gchar *gvir_domain_disk_get_path(GVirDomainDisk *self)
+{
+ GVirConfigDomainDevice *config;
+
+ config = gvir_domain_device_get_config(GVIR_DOMAIN_DEVICE(self));
+
+ return gvir_config_domain_disk_get_target_dev (GVIR_CONFIG_DOMAIN_DISK (config));
+}
+
/**
* gvir_domain_disk_get_stats:
* @self: the domain disk
@@ -166,15 +114,15 @@ GVirDomainDiskStats *gvir_domain_disk_get_stats(GVirDomainDisk *self, GError **e
{
GVirDomainDiskStats *ret = NULL;
virDomainBlockStatsStruct stats;
- GVirDomainDiskPrivate *priv;
virDomainPtr handle;
+ gchar *path;
g_return_val_if_fail(GVIR_IS_DOMAIN_DISK(self), NULL);
- priv = self->priv;
handle = gvir_domain_device_get_domain_handle(GVIR_DOMAIN_DEVICE(self));
+ path = gvir_domain_disk_get_path (self);
- if (virDomainBlockStats(handle, priv->path, &stats, sizeof (stats)) < 0) {
+ if (virDomainBlockStats(handle, path, &stats, sizeof (stats)) < 0) {
gvir_set_error_literal(err, GVIR_DOMAIN_DISK_ERROR,
0,
"Unable to get domain disk stats");
@@ -190,6 +138,7 @@ GVirDomainDiskStats *gvir_domain_disk_get_stats(GVirDomainDisk *self, GError **e
end:
virDomainFree(handle);
+ g_free(path);
return ret;
}
@@ -211,13 +160,15 @@ gboolean gvir_domain_disk_resize(GVirDomainDisk *self,
{
gboolean ret = FALSE;
virDomainPtr handle;
+ gchar *path;
g_return_val_if_fail(GVIR_IS_DOMAIN_DISK(self), FALSE);
g_return_val_if_fail(err == NULL || *err != NULL, FALSE);
handle = gvir_domain_device_get_domain_handle(GVIR_DOMAIN_DEVICE(self));
+ path = gvir_domain_disk_get_path (self);
- if (virDomainBlockResize(handle, self->priv->path, size, flags) < 0) {
+ if (virDomainBlockResize(handle, path, size, flags) < 0) {
gvir_set_error_literal(err, GVIR_DOMAIN_DISK_ERROR,
0,
"Failed to resize domain disk");
@@ -228,5 +179,6 @@ gboolean gvir_domain_disk_resize(GVirDomainDisk *self,
end:
virDomainFree(handle);
+ g_free(path);
return ret;
}
diff --git a/libvirt-gobject/libvirt-gobject-domain-interface.c b/libvirt-gobject/libvirt-gobject-domain-interface.c
index 0917e03..0a9bde0 100644
--- a/libvirt-gobject/libvirt-gobject-domain-interface.c
+++ b/libvirt-gobject/libvirt-gobject-domain-interface.c
@@ -36,73 +36,25 @@
struct _GVirDomainInterfacePrivate
{
- gchar *path;
+ gboolean unused;
};
G_DEFINE_TYPE(GVirDomainInterface, gvir_domain_interface, GVIR_TYPE_DOMAIN_DEVICE);
-enum {
- PROP_0,
- PROP_PATH,
-};
-
#define GVIR_DOMAIN_INTERFACE_ERROR gvir_domain_interface_error_quark()
-
static GQuark
gvir_domain_interface_error_quark(void)
{
return g_quark_from_static_string("gvir-domain-interface");
}
-static void gvir_domain_interface_get_property(GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- GVirDomainInterface *self = GVIR_DOMAIN_INTERFACE(object);
- GVirDomainInterfacePrivate *priv = self->priv;
-
- switch (prop_id) {
- case PROP_PATH:
- g_value_set_string(value, priv->path);
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
- }
-}
-
-
-static void gvir_domain_interface_set_property(GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- GVirDomainInterface *self = GVIR_DOMAIN_INTERFACE(object);
- GVirDomainInterfacePrivate *priv = self->priv;
-
- switch (prop_id) {
- case PROP_PATH:
- g_free(priv->path);
- priv->path = g_value_dup_string(value);
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
- }
-}
-
-
static void gvir_domain_interface_finalize(GObject *object)
{
GVirDomainInterface *self = GVIR_DOMAIN_INTERFACE(object);
- GVirDomainInterfacePrivate *priv = self->priv;
g_debug("Finalize GVirDomainInterface=%p", self);
- g_free(priv->path);
-
G_OBJECT_CLASS(gvir_domain_interface_parent_class)->finalize(object);
}
@@ -111,19 +63,6 @@ static void gvir_domain_interface_class_init(GVirDomainInterfaceClass *klass)
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = gvir_domain_interface_finalize;
- object_class->get_property = gvir_domain_interface_get_property;
- object_class->set_property = gvir_domain_interface_set_property;
-
- g_object_class_install_property(object_class,
- PROP_PATH,
- g_param_spec_string("path",
- "Path",
- "The interface path",
- NULL,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_STRINGS));
-
g_type_class_add_private(klass, sizeof(GVirDomainInterfacePrivate));
}
@@ -140,17 +79,28 @@ gvir_domain_interface_stats_copy(GVirDomainInterfaceStats *stats)
return g_slice_dup(GVirDomainInterfaceStats, stats);
}
-
static void
gvir_domain_interface_stats_free(GVirDomainInterfaceStats *stats)
{
g_slice_free(GVirDomainInterfaceStats, stats);
}
-
G_DEFINE_BOXED_TYPE(GVirDomainInterfaceStats, gvir_domain_interface_stats,
gvir_domain_interface_stats_copy, gvir_domain_interface_stats_free)
+static gchar *gvir_domain_interface_get_path(GVirDomainInterface *self)
+{
+ GVirConfigDomainDevice *config;
+ gchar *path = NULL;
+
+ config = gvir_domain_device_get_config(GVIR_DOMAIN_DEVICE(self));
+ path = gvir_config_domain_interface_get_ifname(GVIR_CONFIG_DOMAIN_INTERFACE (config));
+
+ g_object_unref (config);
+
+ return path;
+}
+
/**
* gvir_domain_interface_get_stats:
* @self: the domain interface
@@ -166,15 +116,15 @@ GVirDomainInterfaceStats *gvir_domain_interface_get_stats(GVirDomainInterface *s
{
GVirDomainInterfaceStats *ret = NULL;
virDomainInterfaceStatsStruct stats;
- GVirDomainInterfacePrivate *priv;
virDomainPtr handle;
+ gchar *path;
g_return_val_if_fail(GVIR_IS_DOMAIN_INTERFACE(self), NULL);
- priv = self->priv;
handle = gvir_domain_device_get_domain_handle(GVIR_DOMAIN_DEVICE(self));
+ path = gvir_domain_interface_get_path (self);
- if (virDomainInterfaceStats(handle, priv->path, &stats, sizeof (stats)) < 0) {
+ if (virDomainInterfaceStats(handle, path, &stats, sizeof (stats)) < 0) {
gvir_set_error_literal(err, GVIR_DOMAIN_INTERFACE_ERROR,
0,
"Unable to get domain interface stats");
@@ -193,5 +143,6 @@ GVirDomainInterfaceStats *gvir_domain_interface_get_stats(GVirDomainInterface *s
end:
virDomainFree(handle);
+ g_free(path);
return ret;
}
--
1.7.7.6
12 years, 9 months