Re: [libvirt] virt-viewer, requirement question
On Fri, Nov 18, 2011 at 03:38:07PM -0800, Jason Helfman wrote: I see that this was moved to vncconnection.h, however I don't see this patch in there. Is this patch still relevant to the code? http://osdir.com/ml/gtk-vnc-list/2009-11/msg00029.html Thanks, Jason This has already been fixed by FreeBSD Gnome team, and will be updated when 9 comes out. Do you have a pointer to the patch they applied to gtk-vnc ? I would like to apply it to the upstream GTK-VNC sources, so you don't need to carry it separately in the future. Daniel -- |: http://berrange.com -o-http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [virt-tools-list] [osinfo PATCH 1/8] Add #include string.h for strcmp
On Fri, Nov 18, 2011 at 11:26:21AM -0700, Eric Blake wrote: [adding virt-tools-list] On 11/18/2011 11:04 AM, Christophe Fergeau wrote: --- tools/osinfo-detect.c |1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/tools/osinfo-detect.c b/tools/osinfo-detect.c index 6afa30a..be36afb 100644 --- a/tools/osinfo-detect.c +++ b/tools/osinfo-detect.c @@ -23,6 +23,7 @@ */ #include osinfo/osinfo.h +#include string.h I've typically seen libosinfo patches sent to virt-tools-l...@redhat.com. However, I just glanced through README in libosinfo.git and didn't see any mention of the preferred address for patch submission, nor mention of a project web page. Those would be some useful patches, to help steer further patches to the best list. I'll change the README for that. As to patch 1/8, it's trivial enough that I can ACK, even if I haven't done anything else with libosinfo myself (I'll leave others to review the rest of the series). ACK to all the other patches too Daniel -- |: http://berrange.com -o-http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] Fix build on Mingw32 wrt export of virNetServerGetDBusConn
From: Daniel P. Berrange berra...@redhat.com Mingw32 complains if you request export of a symbol which does not in fact exist. * src/libvirt_bridge.syms, src/libvirt_macvtap.syms: Delete obsolete files * src/libvirt_private.syms: Remove virNetServerGetDBusConn * src/libvirt_dbus.syms: Add virNetServerGetDBusConn --- src/Makefile.am |8 ++-- src/libvirt_bridge.syms | 23 --- src/libvirt_dbus.syms|2 ++ src/libvirt_macvtap.syms | 10 -- src/libvirt_private.syms |1 - 5 files changed, 4 insertions(+), 40 deletions(-) delete mode 100644 src/libvirt_bridge.syms create mode 100644 src/libvirt_dbus.syms delete mode 100644 src/libvirt_macvtap.syms diff --git a/src/Makefile.am b/src/Makefile.am index f82be78..2ee42a1 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1175,16 +1175,12 @@ if WITH_DRIVER_MODULES USED_SYM_FILES += libvirt_driver_modules.syms endif -if WITH_BRIDGE -USED_SYM_FILES += libvirt_bridge.syms -endif - if WITH_LINUX USED_SYM_FILES += libvirt_linux.syms endif -if WITH_MACVTAP -USED_SYM_FILES += libvirt_macvtap.syms +if HAVE_DBUS +USED_SYM_FILES += libvirt_dbus.syms endif if WITH_LIBVIRTD diff --git a/src/libvirt_bridge.syms b/src/libvirt_bridge.syms deleted file mode 100644 index 626f6ee..000 --- a/src/libvirt_bridge.syms +++ /dev/null @@ -1,23 +0,0 @@ -# -# These symbols are dependent upon --with-qemu or --with-lxc via -# WITH_BRIDGE. -# - - -# bridge.h -brAddBridge; -brAddInetAddress; -brAddInterface; -brAddTap; -brCreateTap; -brDelInetAddress; -brDeleteBridge; -brDeleteTap; -brHasBridge; -brInit; -brSetEnableSTP; -brSetForwardDelay; -brSetInetNetmask; -brSetInterfaceMac; -brSetInterfaceUp; -brShutdown; diff --git a/src/libvirt_dbus.syms b/src/libvirt_dbus.syms new file mode 100644 index 000..a460ec5 --- /dev/null +++ b/src/libvirt_dbus.syms @@ -0,0 +1,2 @@ +# virnetserver.h +virNetServerGetDBusConn; diff --git a/src/libvirt_macvtap.syms b/src/libvirt_macvtap.syms deleted file mode 100644 index b48565b..000 --- a/src/libvirt_macvtap.syms +++ /dev/null @@ -1,10 +0,0 @@ -# -# These symbols are dependent on WITH_MACVTAP. -# - - -# macvtap.h -delMacvtap; -openMacvtapTap; -vpAssociatePortProfileId; -vpDisassociatePortProfileId; diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 7906f5d..f4e25c1 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1252,7 +1252,6 @@ virNetServerAddSignalHandler; virNetServerAutoShutdown; virNetServerClose; virNetServerFree; -virNetServerGetDBusConn; virNetServerIsPrivileged; virNetServerNew; virNetServerQuit; -- 1.7.6.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] Bug Fix: Do not release network actual device in qemuBuildCommandLine on error
On 11/16/2011 09:34 PM, Roopa Prabhu wrote: From: Roopa Prabhuropra...@cisco.com For direct attach devices, in qemuBuildCommandLine, we seem to be freeing actual device on error path (with networkReleaseActualDevice). But the actual device is not deleted. qemuProcessStop eventually deletes the direct attach device and releases actual device. But by the time qemuProcessStop is called qemuBuildCommandLine has already freed actual device. Leaving stray macvtap devices behind on error. So the simplest fix is to remove the networkReleaseActualDevice in qemuBuildCommandLine. This patch does just that. Does this look right ?. I have only verified this with direct and bridge mode. You're right and to me your patch looks ok too. When using the interface type=network and then network in 'macvtap direction connection' mode [1] and an error happens in qemuBuildCommandLine I also see a stray macvtap device left behind. We're calling networkReleaseActualDevice two times and that seems to not work in this configuration. In the case when macvtap is used via interface type='direct' it works fine with or without your patch. [1] file:///root/tmp/libvirt-acl/docs/formatnetwork.html#examplesDirect Stefan The other option is to do both delMacvtap and networkReleaseActualDevice in qemuBuildCommandLine instead of doing only networkReleaseActualDevice. I do have a patch for this too. Signed-off-by: Roopa Prabhuropra...@cisco.com --- src/qemu/qemu_command.c |2 -- 1 files changed, 0 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index bb12016..ba33a4a 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -5378,8 +5378,6 @@ qemuBuildCommandLine(virConnectPtr conn, virReportOOMError(); error: /* free up any resources in the network driver */ -for (i = 0 ; i def-nnets ; i++) -networkReleaseActualDevice(def-nets[i]); for (i = 0; i= last_good_net; i++) virDomainConfNWFilterTeardown(def-nets[i]); virCommandFree(cmd); -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [TCK] [PATCH] nwfilter: Add '-n' flag to iptables command where missing
Add the -n flag to the iptables command where it is missing to avoid delays due to name resolution. --- scripts/nwfilter/nwfilterxml2fwallout/all-test.fwall |9 + scripts/nwfilter/nwfilterxml2fwallout/target-test.fwall |8 scripts/nwfilter/nwfilterxml2fwallout/target-test2.fwall |8 3 files changed, 13 insertions(+), 12 deletions(-) Index: libvirt-tck/scripts/nwfilter/nwfilterxml2fwallout/all-test.fwall === --- libvirt-tck.orig/scripts/nwfilter/nwfilterxml2fwallout/all-test.fwall +++ libvirt-tck/scripts/nwfilter/nwfilterxml2fwallout/all-test.fwall @@ -24,7 +24,8 @@ FI-vnet0 all -- 0.0.0.0/0 0.0.0.0/0 [got ACCEPT all -- 0.0.0.0/00.0.0.0/0 PHYSDEV match --physdev-in vnet0 #iptables -L libvirt-out -n | grep vnet0 | tr -s FO-vnet0 all -- 0.0.0.0/0 0.0.0.0/0 [goto] PHYSDEV match --physdev-out vnet0 -#iptables -L FORWARD --line-number | grep libvirt -1libvirt-in all -- anywhere anywhere -2libvirt-out all -- anywhere anywhere -3libvirt-in-post all -- anywhere anywhere +#iptables -L FORWARD -n --line-number | grep libvirt +1libvirt-in all -- 0.0.0.0/00.0.0.0/0 +2libvirt-out all -- 0.0.0.0/00.0.0.0/0 +3libvirt-in-post all -- 0.0.0.0/00.0.0.0/0 + Index: libvirt-tck/scripts/nwfilter/nwfilterxml2fwallout/target-test.fwall === --- libvirt-tck.orig/scripts/nwfilter/nwfilterxml2fwallout/target-test.fwall +++ libvirt-tck/scripts/nwfilter/nwfilterxml2fwallout/target-test.fwall @@ -42,10 +42,10 @@ FI-vnet0 all -- 0.0.0.0/0 0.0.0.0/0 [got ACCEPT all -- 0.0.0.0/00.0.0.0/0 PHYSDEV match --physdev-in vnet0 #iptables -L libvirt-out -n | grep vnet0 | tr -s FO-vnet0 all -- 0.0.0.0/0 0.0.0.0/0 [goto] PHYSDEV match --physdev-out vnet0 -#iptables -L FORWARD --line-number | grep libvirt -1libvirt-in all -- anywhere anywhere -2libvirt-out all -- anywhere anywhere -3libvirt-in-post all -- anywhere anywhere +#iptables -L FORWARD -n --line-number | grep libvirt +1libvirt-in all -- 0.0.0.0/00.0.0.0/0 +2libvirt-out all -- 0.0.0.0/00.0.0.0/0 +3libvirt-in-post all -- 0.0.0.0/00.0.0.0/0 #ebtables -t nat -L PREROUTING | grep vnet0 | grep -v ^Bridge | grep -v ^$ -i vnet0 -j libvirt-I-vnet0 #ebtables -t nat -L POSTROUTING | grep vnet0 | grep -v ^Bridge | grep -v ^$ Index: libvirt-tck/scripts/nwfilter/nwfilterxml2fwallout/target-test2.fwall === --- libvirt-tck.orig/scripts/nwfilter/nwfilterxml2fwallout/target-test2.fwall +++ libvirt-tck/scripts/nwfilter/nwfilterxml2fwallout/target-test2.fwall @@ -27,8 +27,8 @@ FI-vnet0 all -- 0.0.0.0/0 0.0.0.0/0 [got ACCEPT all -- 0.0.0.0/00.0.0.0/0 PHYSDEV match --physdev-in vnet0 #iptables -L libvirt-out -n | grep vnet0 | tr -s FO-vnet0 all -- 0.0.0.0/0 0.0.0.0/0 [goto] PHYSDEV match --physdev-out vnet0 -#iptables -L FORWARD --line-number | grep libvirt -1libvirt-in all -- anywhere anywhere -2libvirt-out all -- anywhere anywhere -3libvirt-in-post all -- anywhere anywhere +#iptables -L FORWARD -n --line-number | grep libvirt +1libvirt-in all -- 0.0.0.0/00.0.0.0/0 +2libvirt-out all -- 0.0.0.0/00.0.0.0/0 +3libvirt-in-post all -- 0.0.0.0/00.0.0.0/0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [TCK][PATCH] add more test cases
This patch adds a couple more test cases (especially for IPv6 configurations) to the network test 100. Again make sure that some of the parameters from tck-testnet's XML have made it into command line parameters of dnsmasq. --- scripts/networks/networkxml2hostout/tck-testnet-3.dat | 49 + scripts/networks/networkxml2hostout/tck-testnet-3.post.dat | 19 + scripts/networks/networkxml2xmlin/tck-testnet-3.xml| 22 + 3 files changed, 90 insertions(+) Index: libvirt-tck/scripts/networks/networkxml2xmlin/tck-testnet-3.xml === --- /dev/null +++ libvirt-tck/scripts/networks/networkxml2xmlin/tck-testnet-3.xml @@ -0,0 +1,22 @@ +network + nametck-testnet/name + uuidaadc8920-502a-4774-ac2b-cd382a204d06/uuid + bridge name=tck-testbr / + forward mode=nat / + ip address=10.1.2.1 netmask=255.255.255.0 +dhcp + range start=10.1.2.2 end=10.1.2.254 / + host mac=00:16:3e:77:e2:ed name=a.example.com ip=10.1.2.10 / + host mac=00:16:3e:3e:a9:1a name=b.example.com ip=10.1.2.11 / +/dhcp + /ip + ip family=ipv4 address=192.168.123.1 netmask=255.255.255.0 + /ip + ip family=ipv6 address=2001:db8:ac10:fe01::1 prefix=64 + /ip + ip family=ipv6 address=2001:db8:ac10:fd01::1 prefix=64 + /ip + ip family=ipv4 address=172.28.255.241 netmask=255.255.255.240 + /ip +/network + Index: libvirt-tck/scripts/networks/networkxml2hostout/tck-testnet-3.dat === --- /dev/null +++ libvirt-tck/scripts/networks/networkxml2hostout/tck-testnet-3.dat @@ -0,0 +1,49 @@ +#iptables -t nat -L -n | grep ' 10\.1\.2\.' +MASQUERADE tcp -- 10.1.2.0/24 !10.1.2.0/24 masq ports: 1024-65535 +MASQUERADE udp -- 10.1.2.0/24 !10.1.2.0/24 masq ports: 1024-65535 +MASQUERADE all -- 10.1.2.0/24 !10.1.2.0/24 +#iptables -n -L FORWARD | grep ' 10\.1\.2\.' +ACCEPT all -- 0.0.0.0/010.1.2.0/24 state RELATED,ESTABLISHED +ACCEPT all -- 10.1.2.0/24 0.0.0.0/0 +#ip6tables -n -L FORWARD | grep ' 2001:db8:ac10' +ACCEPT all ::/0 2001:db8:ac10:fd01::/64 +ACCEPT all 2001:db8:ac10:fd01::/64 ::/0 +ACCEPT all ::/0 2001:db8:ac10:fe01::/64 +ACCEPT all 2001:db8:ac10:fe01::/64 ::/0 +#ps aux | sed -n '/dnsmasq .*tck-testnet/ s|.*\(listen-address 10\.1\.2\.1\).*|\1|p' +listen-address 10.1.2.1 +#ps aux | sed -n '/dnsmasq .*tck-testnet/ s|.*\(listen-address 192\.168\.123\.1\).*|\1|p' +listen-address 192.168.123.1 +#ps aux | sed -n '/dnsmasq .*tck-testnet/ s|.*\(listen-address 172\.28\.255\.241\).*|\1|p' +listen-address 172.28.255.241 +#ps aux | sed -n '/dnsmasq .*tck-testnet/ s|.*\(dhcp-range 10\.1\.2\.2,10\.1\.2\.254\).*|\1|p' +dhcp-range 10.1.2.2,10.1.2.254 +#ps aux | sed -n '/dnsmasq .*tck-testnet/ s|.*\(listen-address 2001\:db8\:ac10\:fe01\:\:1\).*|\1|p' +listen-address 2001:db8:ac10:fe01::1 +#ps aux | sed -n '/dnsmasq .*tck-testnet/ s|.*\(listen-address 2001\:db8\:ac10\:fd01\:\:1\).*|\1|p' +listen-address 2001:db8:ac10:fd01::1 +#ps aux | sed -n '/radvd --.*tck-testnet-/ s|.*\(\/radvd\/tck-testnet-radvd.conf\).*|\1|p' +/radvd/tck-testnet-radvd.conf +#route -n | grep '10\.1\.2\.' +10.1.2.00.0.0.0 255.255.255.0 U 0 00 tck-testbr +#route -n | grep '192\.168\.123\.' +192.168.123.0 0.0.0.0 255.255.255.0 U 0 00 tck-testbr +#route -n | grep '172\.28\.255\.240' +172.28.255.240 0.0.0.0 255.255.255.240 U 0 00 tck-testbr +#brctl show | grep tck-testbr | gawk '{print $1 $3}' +tck-testbr yes +#ifconfig tck-testbr | grep ':10\.1\.2\.' + inet addr:10.1.2.1 Bcast:10.1.2.255 Mask:255.255.255.0 +#ifconfig tck-testbr | grep 'inet6 addr: 2001' + inet6 addr: 2001:db8:ac10:fd01::1/64 Scope:Global + inet6 addr: 2001:db8:ac10:fe01::1/64 Scope:Global +#ip addr show tck-testbr | grep inet +inet 10.1.2.1/24 brd 10.1.2.255 scope global tck-testbr +inet 192.168.123.1/24 brd 192.168.123.255 scope global tck-testbr +inet 172.28.255.241/28 brd 172.28.255.255 scope global tck-testbr +#ip route show dev tck-testbr +172.28.255.240/28 proto kernel scope link src 172.28.255.241 +10.1.2.0/24 proto kernel scope link src 10.1.2.1 +192.168.123.0/24 proto kernel scope link src 192.168.123.1 +#virsh net-list | grep tck-testnet +tck-testnet active no Index: libvirt-tck/scripts/networks/networkxml2hostout/tck-testnet-3.post.dat === --- /dev/null +++ libvirt-tck/scripts/networks/networkxml2hostout/tck-testnet-3.post.dat @@ -0,0 +1,19 @@ +#iptables -t nat -L -n | grep ' 10\.1\.2\.' +#iptables -n -L FORWARD | grep ' 10\.1\.2\.' +#ip6tables -n -L FORWARD | grep ' 2001:db8:ac10' +#ps aux | sed -n
[libvirt] [TCK][PATCH] nwfilter: Add test cases for vlan and stp filtering
Add test cases for VLAN and (upcoming) STP. --- scripts/nwfilter/nwfilterxml2fwallout/stp-test.fwall | 14 + scripts/nwfilter/nwfilterxml2fwallout/vlan-test.fwall | 15 ++ scripts/nwfilter/nwfilterxml2xmlin/stp-test.xml | 26 ++ scripts/nwfilter/nwfilterxml2xmlin/vlan-test.xml | 45 ++ 4 files changed, 100 insertions(+) Index: libvirt-tck/scripts/nwfilter/nwfilterxml2fwallout/vlan-test.fwall === --- /dev/null +++ libvirt-tck/scripts/nwfilter/nwfilterxml2fwallout/vlan-test.fwall @@ -0,0 +1,15 @@ +#ebtables -t nat -L libvirt-I-vnet0 | grep -v ^Bridge | grep -v ^$ +-p 802_1Q -s aa:bb:cc:dd:ee:ff -d 1:2:3:4:5:6 --vlan-id 291 -j CONTINUE +-p 802_1Q -s aa:bb:cc:dd:ee:ff -d 1:2:3:4:5:6 --vlan-id 1234 -j RETURN +-p 802_1Q -s 1:2:3:4:5:6 -d aa:bb:cc:dd:ee:ff --vlan-encap 2054 -j DROP +-p 802_1Q -s 1:2:3:4:5:6 -d aa:bb:cc:dd:ee:ff --vlan-encap 4660 -j ACCEPT +#ebtables -t nat -L libvirt-O-vnet0 | grep -v ^Bridge | grep -v ^$ +-p 802_1Q -s 1:2:3:4:5:6 -d aa:bb:cc:dd:ee:ff --vlan-id 291 -j CONTINUE +-p 802_1Q -s 1:2:3:4:5:6 -d aa:bb:cc:dd:ee:ff --vlan-id 1234 -j RETURN +-p 802_1Q -s 1:2:3:4:5:6 -d aa:bb:cc:dd:ee:ff --vlan-id 291 -j DROP +-p 802_1Q -s 1:2:3:4:5:6 -d aa:bb:cc:dd:ee:ff -j ACCEPT +#ebtables -t nat -L PREROUTING | grep vnet0 +-i vnet0 -j libvirt-I-vnet0 +#ebtables -t nat -L POSTROUTING | grep vnet0 +-o vnet0 -j libvirt-O-vnet0 + Index: libvirt-tck/scripts/nwfilter/nwfilterxml2xmlin/vlan-test.xml === --- /dev/null +++ libvirt-tck/scripts/nwfilter/nwfilterxml2xmlin/vlan-test.xml @@ -0,0 +1,45 @@ +filter name='tck-testcase' chain='root' + uuid5c6d49af-b071-6127-b4ec-6f8ed4b55335/uuid + rule action='continue' direction='inout' + vlan srcmacaddr='1:2:3:4:5:6' srcmacmask='ff:ff:ff:ff:ff:ff' + dstmacaddr='aa:bb:cc:dd:ee:ff' dstmacmask='ff:ff:ff:ff:ff:ff' + vlanid='0x123' + / + /rule + + rule action='return' direction='inout' + vlan srcmacaddr='1:2:3:4:5:6' srcmacmask='ff:ff:ff:ff:ff:ff' + dstmacaddr='aa:bb:cc:dd:ee:ff' dstmacmask='ff:ff:ff:ff:ff:ff' + vlanid='1234' + / + /rule + + rule action='reject' direction='in' + vlan srcmacaddr='1:2:3:4:5:6' srcmacmask='ff:ff:ff:ff:ff:ff' + dstmacaddr='aa:bb:cc:dd:ee:ff' dstmacmask='ff:ff:ff:ff:ff:ff' + vlanid='0x123' + / + /rule + + rule action='accept' direction='in' + vlan srcmacaddr='1:2:3:4:5:6' srcmacmask='ff:ff:ff:ff:ff:ff' + dstmacaddr='aa:bb:cc:dd:ee:ff' dstmacmask='ff:ff:ff:ff:ff:ff' + vlanid='0x' + / + /rule + + rule action='drop' direction='out' + vlan srcmacaddr='1:2:3:4:5:6' srcmacmask='ff:ff:ff:ff:ff:ff' + dstmacaddr='aa:bb:cc:dd:ee:ff' dstmacmask='ff:ff:ff:ff:ff:ff' + encap-protocol='arp' + / + /rule + + rule action='accept' direction='out' + vlan srcmacaddr='1:2:3:4:5:6' srcmacmask='ff:ff:ff:ff:ff:ff' + dstmacaddr='aa:bb:cc:dd:ee:ff' dstmacmask='ff:ff:ff:ff:ff:ff' + encap-protocol='0x1234' + / + /rule + +/filter Index: libvirt-tck/scripts/nwfilter/nwfilterxml2fwallout/stp-test.fwall === --- /dev/null +++ libvirt-tck/scripts/nwfilter/nwfilterxml2fwallout/stp-test.fwall @@ -0,0 +1,14 @@ +#ebtables -t nat -L libvirt-I-vnet0 | grep -v ^Bridge | grep -v ^$ +-d BGA -j I-vnet0-stp-xyz +#ebtables -t nat -L libvirt-O-vnet0 | grep -v ^Bridge | grep -v ^$ +-d BGA -j O-vnet0-stp-xyz +#ebtables -t nat -L PREROUTING | grep vnet0 +-i vnet0 -j libvirt-I-vnet0 +#ebtables -t nat -L POSTROUTING | grep vnet0 +-o vnet0 -j libvirt-O-vnet0 +#ebtables -t nat -L I-vnet0-stp-xyz | grep -v ^Bridge | grep -v ^$ +-s 1:2:3:4:5:6 -d BGA --stp-root-prio 4660:9029 --stp-root-addr 6:5:4:3:2:1 --stp-root-cost 287454020:573785173 -j RETURN +#ebtables -t nat -L O-vnet0-stp-xyz | grep -v ^Bridge | grep -v ^$ +-s 1:2:3:4:5:6 -d BGA --stp-type 18 --stp-flags 68 -j CONTINUE +-s 1:2:3:4:5:6 -d BGA --stp-sender-prio 4660 --stp-sender-addr 6:5:4:3:2:1 --stp-port 123:234 --stp-msg-age 5544: --stp-max-age : --stp-hello-time 12345:12346 --stp-forward-delay 54321:65432 -j DROP + Index: libvirt-tck/scripts/nwfilter/nwfilterxml2xmlin/stp-test.xml === --- /dev/null +++ libvirt-tck/scripts/nwfilter/nwfilterxml2xmlin/stp-test.xml @@ -0,0 +1,26 @@ +filter name='tck-testcase' chain='stp-xyz' + uuid5c6d49af-b071-6127-b4ec-6f8ed4b55335/uuid + rule action='continue' direction='in' + stp srcmacaddr='1:2:3:4:5:6' srcmacmask='ff:ff:ff:ff:ff:ff' + type='0x12' flags='0x44'/ + /rule + + rule action='return' direction='out' + stp srcmacaddr='1:2:3:4:5:6' srcmacmask='ff:ff:ff:ff:ff:ff' + root-priority='0x1234' root-priority-hi='0x2345' + root-address=6:5:4:3:2:1
[libvirt] [TCK] [PATCH] networks: Fix some errors in test 100
Network test 100 when run via sh ./networkApplyTest.sh --tap-test --verbose --wait currently exhibits some problems. This patch fixes them. I now only looking for dnsmasq to be running with some of the parameters from tck-testnet having gone into its command line arguments. --- scripts/networks/networkxml2hostout/tck-testnet-1.dat | 10 ++ scripts/networks/networkxml2hostout/tck-testnet-1.post.dat |6 -- scripts/networks/networkxml2hostout/tck-testnet-2.dat | 10 ++ scripts/networks/networkxml2hostout/tck-testnet-2.post.dat |5 +++-- 4 files changed, 19 insertions(+), 12 deletions(-) Index: libvirt-tck/scripts/networks/networkxml2hostout/tck-testnet-1.dat === --- libvirt-tck.orig/scripts/networks/networkxml2hostout/tck-testnet-1.dat +++ libvirt-tck/scripts/networks/networkxml2hostout/tck-testnet-1.dat @@ -5,12 +5,14 @@ MASQUERADE all -- 10.1.2.0/24 #iptables -n -L FORWARD | grep ' 10\.1\.2\.' ACCEPT all -- 0.0.0.0/010.1.2.0/24 state RELATED,ESTABLISHED ACCEPT all -- 10.1.2.0/24 0.0.0.0/0 -#ps aux | sed -n '/dnsmasq .*10\.1\.2\./ s|.*\(dnsmasq[[:print:]*]\)|\1|p' -dnsmasq --strict-order --bind-interfaces --pid-file=/var/run/libvirt/network/tck-testnet.pid --conf-file= --listen-address 10.1.2.1 --except-interface lo --dhcp-range 10.1.2.2,10.1.2.254 --dhcp-lease-max=253 --dhcp-no-override +#ps aux | sed -n '/dnsmasq .*tck-testnet/ s|.*\(listen-address 10\.1\.2\.1*\).*|\1|p' +listen-address 10.1.2.1 +#ps aux | sed -n '/dnsmasq .*tck-testnet/ s|.*\(dhcp-range 10\.1\.2\.2\,10\.1\.2\.254*\).*|\1|p' +dhcp-range 10.1.2.2,10.1.2.254 #route -n | grep '10\.1\.2\.' 10.1.2.00.0.0.0 255.255.255.0 U 0 00 tck-testbr -#brctl show | grep tck-testbr -tck-testbr 8000. yes +#brctl show | grep tck-testbr | gawk '{print $1 $3}' +tck-testbr yes #ifconfig tck-testbr | grep ':10\.1\.2\.' inet addr:10.1.2.1 Bcast:10.1.2.255 Mask:255.255.255.0 #virsh net-list | grep tck-testnet Index: libvirt-tck/scripts/networks/networkxml2hostout/tck-testnet-1.post.dat === --- libvirt-tck.orig/scripts/networks/networkxml2hostout/tck-testnet-1.post.dat +++ libvirt-tck/scripts/networks/networkxml2hostout/tck-testnet-1.post.dat @@ -1,7 +1,9 @@ #iptables -t nat -L -n | grep ' 10\.1\.2\.' #iptables -n -L FORWARD | grep ' 10\.1\.2\.' -#ps aux | sed -n '/dnsmasq .*10\.1\.2\./ s|.*\(dnsmasq[[:print:]*]\)|\1|p' +#ps aux | sed -n '/dnsmasq .*tck-testnet/ s|.*\(listen-address 10\.1\.2\.1*\).*|\1|p' +#ps aux | sed -n '/dnsmasq .*tck-testnet/ s|.*\(dhcp-range 10\.1\.2\.2\,10\.1\.2\.254*\).*|\1|p' #route -n | grep '10\.1\.2\.' -#brctl show | grep tck-testbr +#route -n | grep '10\.1\.2\.' +#brctl show | grep tck-testbr | gawk '{print $1 $3}' #ifconfig tck-testbr 2/dev/null| grep ':10\.1\.2\.' #virsh net-list | grep tck-testnet Index: libvirt-tck/scripts/networks/networkxml2hostout/tck-testnet-2.dat === --- libvirt-tck.orig/scripts/networks/networkxml2hostout/tck-testnet-2.dat +++ libvirt-tck/scripts/networks/networkxml2hostout/tck-testnet-2.dat @@ -2,12 +2,14 @@ ACCEPT all -- 0.0.0.0/010.1.2.0/24 ACCEPT all -- 10.1.2.0/24 0.0.0.0/0 #iptables -t nat -L -n | grep ' 10\.1\.2\.' -#ps aux | sed -n '/dnsmasq .*10\.1\.2\./ s|.*\(dnsmasq[[:print:]*]\)|\1|p' -dnsmasq --strict-order --bind-interfaces --pid-file=/var/run/libvirt/network/tck-testnet.pid --conf-file= --listen-address 10.1.2.1 --except-interface lo --dhcp-range 10.1.2.2,10.1.2.254 --dhcp-lease-max=253 --dhcp-no-override +#ps aux | sed -n '/dnsmasq .*tck-testnet/ s|.*\(listen-address 10\.1\.2\.1\).*|\1|p' +listen-address 10.1.2.1 +#ps aux | sed -n '/dnsmasq .*tck-testnet/ s|.*\(dhcp-range 10\.1\.2\.2,10\.1\.2\.254\).*|\1|p' +dhcp-range 10.1.2.2,10.1.2.254 #route -n | grep '10\.1\.2\.' 10.1.2.00.0.0.0 255.255.255.0 U 0 00 tck-testbr -#brctl show | grep tck-testbr -tck-testbr 8000. yes +#brctl show | grep tck-testbr | gawk '{print $1 $3}' +tck-testbr yes #ifconfig tck-testbr | grep ':10\.1\.2\.' inet addr:10.1.2.1 Bcast:10.1.2.255 Mask:255.255.255.0 #virsh net-list | grep tck-testnet Index: libvirt-tck/scripts/networks/networkxml2hostout/tck-testnet-2.post.dat === --- libvirt-tck.orig/scripts/networks/networkxml2hostout/tck-testnet-2.post.dat +++ libvirt-tck/scripts/networks/networkxml2hostout/tck-testnet-2.post.dat @@ -1,7 +1,8 @@ #iptables -t nat -L -n | grep ' 10\.1\.2' #iptables -n -L FORWARD | grep ' 10\.1\.2' -#ps aux | sed -n '/dnsmasq .*10\.1\.2\./
Re: [libvirt] [TCK] [PATCH] nwfilter: Add '-n' flag to iptables command where missing
On Mon, Nov 21, 2011 at 07:20:28AM -0500, Stefan Berger wrote: Add the -n flag to the iptables command where it is missing to avoid delays due to name resolution. --- scripts/nwfilter/nwfilterxml2fwallout/all-test.fwall |9 + scripts/nwfilter/nwfilterxml2fwallout/target-test.fwall |8 scripts/nwfilter/nwfilterxml2fwallout/target-test2.fwall |8 3 files changed, 13 insertions(+), 12 deletions(-) ACK Daniel -- |: http://berrange.com -o-http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [TCK][PATCH] add more test cases
On Mon, Nov 21, 2011 at 07:40:14AM -0500, Stefan Berger wrote: This patch adds a couple more test cases (especially for IPv6 configurations) to the network test 100. Again make sure that some of the parameters from tck-testnet's XML have made it into command line parameters of dnsmasq. --- scripts/networks/networkxml2hostout/tck-testnet-3.dat | 49 + scripts/networks/networkxml2hostout/tck-testnet-3.post.dat | 19 + scripts/networks/networkxml2xmlin/tck-testnet-3.xml| 22 + 3 files changed, 90 insertions(+) ACK Daniel -- |: http://berrange.com -o-http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [TCK][PATCH] nwfilter: Add test cases for vlan and stp filtering
On Mon, Nov 21, 2011 at 07:43:49AM -0500, Stefan Berger wrote: Add test cases for VLAN and (upcoming) STP. --- scripts/nwfilter/nwfilterxml2fwallout/stp-test.fwall | 14 + scripts/nwfilter/nwfilterxml2fwallout/vlan-test.fwall | 15 ++ scripts/nwfilter/nwfilterxml2xmlin/stp-test.xml | 26 ++ scripts/nwfilter/nwfilterxml2xmlin/vlan-test.xml | 45 ++ 4 files changed, 100 insertions(+) ACK Daniel -- |: http://berrange.com -o-http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [TCK] [PATCH] networks: Fix some errors in test 100
On Mon, Nov 21, 2011 at 07:26:18AM -0500, Stefan Berger wrote: Network test 100 when run via sh ./networkApplyTest.sh --tap-test --verbose --wait currently exhibits some problems. This patch fixes them. I now only looking for dnsmasq to be running with some of the parameters from tck-testnet having gone into its command line arguments. --- scripts/networks/networkxml2hostout/tck-testnet-1.dat | 10 ++ scripts/networks/networkxml2hostout/tck-testnet-1.post.dat |6 -- scripts/networks/networkxml2hostout/tck-testnet-2.dat | 10 ++ scripts/networks/networkxml2hostout/tck-testnet-2.post.dat |5 +++-- 4 files changed, 19 insertions(+), 12 deletions(-) ACK Daniel -- |: http://berrange.com -o-http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 2/2] nwfilter: use shell variable to invoke 'ip(6)tables' command
Introduce a shell variable 'IBT' to invoke the ip(6)tables command. Tested with libvirt-tck. --- src/nwfilter/nwfilter_ebiptables_driver.c | 313 ++ 1 file changed, 155 insertions(+), 158 deletions(-) Index: libvirt-acl/src/nwfilter/nwfilter_ebiptables_driver.c === --- libvirt-acl.orig/src/nwfilter/nwfilter_ebiptables_driver.c +++ libvirt-acl/src/nwfilter/nwfilter_ebiptables_driver.c @@ -146,6 +146,10 @@ static const char ebiptables_script_set_ #define NWFILTER_SET_EBTABLES_SHELLVAR(BUFPTR) \ virBufferAsprintf(BUFPTR, EBT=%s\n, ebtables_cmd_path); +#define NWFILTER_SET_IPTABLES_SHELLVAR(BUFPTR) \ +virBufferAsprintf(BUFPTR, IPT=%s\n, iptables_cmd_path); +#define NWFILTER_SET_IP6TABLES_SHELLVAR(BUFPTR) \ +virBufferAsprintf(BUFPTR, IPT=%s\n, ip6tables_cmd_path); #define VIRT_IN_CHAIN libvirt-in #define VIRT_OUT_CHAIN libvirt-out @@ -493,66 +497,60 @@ ebtablesHandleEthHdr(virBufferPtr buf, / iptables support / -static int iptablesLinkIPTablesBaseChain(const char *iptables_cmd, - virBufferPtr buf, +static int iptablesLinkIPTablesBaseChain(virBufferPtr buf, const char *udchain, const char *syschain, unsigned int pos, int stopOnError) { virBufferAsprintf(buf, - res=$(%s -L %s -n --line-number | + res=$($IPT -L %s -n --line-number | %s \ %s \)\n if [ $? -ne 0 ]; then\n -%s -I %s %d -j %s\n +$IPT -I %s %d -j %s\n else\n r=$(echo $res | %s '{print $1}')\n if [ \${r}\ != \%d\ ]; then\n - CMD_DEF(%s -I %s %d -j %s) CMD_SEPARATOR + CMD_DEF($IPT -I %s %d -j %s) CMD_SEPARATOR CMD_EXEC %s r=$(( $r + 1 ))\n - CMD_DEF(%s -D %s ${r}) CMD_SEPARATOR + CMD_DEF($IPT -D %s ${r}) CMD_SEPARATOR CMD_EXEC %s fi\n fi\n, - iptables_cmd, syschain, + syschain, grep_cmd_path, udchain, - iptables_cmd, syschain, pos, udchain, + syschain, pos, udchain, gawk_cmd_path, pos, - iptables_cmd, syschain, pos, udchain, + syschain, pos, udchain, CMD_STOPONERR(stopOnError), - iptables_cmd, syschain, + syschain, CMD_STOPONERR(stopOnError)); return 0; } -static int iptablesCreateBaseChains(const char *iptables_cmd, -virBufferPtr buf) +static int iptablesCreateBaseChains(virBufferPtr buf) { -virBufferAsprintf(buf,%s -N VIRT_IN_CHAIN CMD_SEPARATOR - %s -N VIRT_OUT_CHAIN CMD_SEPARATOR - %s -N VIRT_IN_POST_CHAIN CMD_SEPARATOR - %s -N HOST_IN_CHAIN CMD_SEPARATOR, - iptables_cmd, - iptables_cmd, - iptables_cmd, - iptables_cmd); -iptablesLinkIPTablesBaseChain(iptables_cmd, buf, +virBufferAddLit(buf, $IPT -N VIRT_IN_CHAIN CMD_SEPARATOR + $IPT -N VIRT_OUT_CHAIN CMD_SEPARATOR + $IPT -N VIRT_IN_POST_CHAIN CMD_SEPARATOR + $IPT -N HOST_IN_CHAIN CMD_SEPARATOR); +iptablesLinkIPTablesBaseChain(buf, VIRT_IN_CHAIN , FORWARD, 1, 1); -iptablesLinkIPTablesBaseChain(iptables_cmd, buf, +iptablesLinkIPTablesBaseChain(buf, VIRT_OUT_CHAIN, FORWARD, 2, 1); -iptablesLinkIPTablesBaseChain(iptables_cmd, buf, +iptablesLinkIPTablesBaseChain(buf, VIRT_IN_POST_CHAIN, FORWARD, 3, 1); -iptablesLinkIPTablesBaseChain(iptables_cmd, buf, +iptablesLinkIPTablesBaseChain(buf, HOST_IN_CHAIN , INPUT , 1, 1); return 0; @@ -560,8 +558,7 @@ static int iptablesCreateBaseChains(cons static int -iptablesCreateTmpRootChain(const char *iptables_cmd, - virBufferPtr buf, +iptablesCreateTmpRootChain(virBufferPtr buf, char prefix, int
[libvirt] [PATCH 1/2] nwfilter: use shell variable to invoke 'ebtables' command
Introduce a shell variable 'EBT' to invoke the ebtables command. Hard-code the used ebtables table to '-t nat'. Tested with libvirt-tck. --- src/nwfilter/nwfilter_ebiptables_driver.c | 170 +- 1 file changed, 97 insertions(+), 73 deletions(-) Index: libvirt-acl/src/nwfilter/nwfilter_ebiptables_driver.c === --- libvirt-acl.orig/src/nwfilter/nwfilter_ebiptables_driver.c +++ libvirt-acl/src/nwfilter/nwfilter_ebiptables_driver.c @@ -46,7 +46,6 @@ #define VIR_FROM_THIS VIR_FROM_NWFILTER -#define EBTABLES_DEFAULT_TABLE nat #define EBTABLES_CHAIN_INCOMING PREROUTING #define EBTABLES_CHAIN_OUTGOING POSTROUTING @@ -86,7 +85,6 @@ static char *ip6tables_cmd_path; static char *grep_cmd_path; static char *gawk_cmd_path; - #define PRINT_ROOT_CHAIN(buf, prefix, ifname) \ snprintf(buf, sizeof(buf), libvirt-%c-%s, prefix, ifname) #define PRINT_CHAIN(buf, prefix, ifname, suffix) \ @@ -110,7 +108,7 @@ static const char ebtables_script_func_c collect_chains()\n {\n for tmp2 in $*; do\n -for tmp in $(%s -t %s -L $tmp2 | \\\n +for tmp in $($EBT -t nat -L $tmp2 | \\\n sed -n \/Bridge chain/,\\$ s/.*-j ([%s]-.*)/1/p\);\n do\n echo $tmp\n @@ -122,8 +120,8 @@ static const char ebtables_script_func_c static const char ebiptables_script_func_rm_chains[] = rm_chains()\n {\n - for tmp in $*; do %s -t %s -F $tmp; done\n - for tmp in $*; do %s -t %s -X $tmp; done\n + for tmp in $*; do $EBT -t nat -F $tmp; done\n + for tmp in $*; do $EBT -t nat -X $tmp; done\n }\n; static const char ebiptables_script_func_rename_chains[] = @@ -131,8 +129,8 @@ static const char ebiptables_script_func {\n for tmp in $*; do\n case $tmp in\n - %c*) %s -t %s -E $tmp %c${tmp#?} ;;\n - %c*) %s -t %s -E $tmp %c${tmp#?} ;;\n + %c*) $EBT -t nat -E $tmp %c${tmp#?} ;;\n + %c*) $EBT -t nat -E $tmp %c${tmp#?} ;;\n esac\n done\n }\n; @@ -146,6 +144,9 @@ static const char ebiptables_script_set_ #define NWFILTER_FUNC_RENAME_CHAINS ebiptables_script_func_rename_chains #define NWFILTER_FUNC_SET_IFS ebiptables_script_set_ifs +#define NWFILTER_SET_EBTABLES_SHELLVAR(BUFPTR) \ +virBufferAsprintf(BUFPTR, EBT=%s\n, ebtables_cmd_path); + #define VIRT_IN_CHAIN libvirt-in #define VIRT_OUT_CHAIN libvirt-out #define VIRT_IN_POST_CHAIN libvirt-in-post @@ -1990,9 +1991,8 @@ ebtablesCreateRuleInstance(char chainPre case VIR_NWFILTER_RULE_PROTOCOL_MAC: virBufferAsprintf(buf, - CMD_DEF_PRE %s -t %s -%%c %s %%s, - ebtables_cmd_path, EBTABLES_DEFAULT_TABLE, chain); - + CMD_DEF_PRE $EBT -t nat -%%c %s %%s, + chain); if (ebtablesHandleEthHdr(buf, vars, @@ -2015,8 +2015,8 @@ ebtablesCreateRuleInstance(char chainPre case VIR_NWFILTER_RULE_PROTOCOL_VLAN: virBufferAsprintf(buf, - CMD_DEF_PRE %s -t %s -%%c %s %%s, - ebtables_cmd_path, EBTABLES_DEFAULT_TABLE, chain); + CMD_DEF_PRE $EBT -t nat -%%c %s %%s, + chain); if (ebtablesHandleEthHdr(buf, @@ -2082,8 +2082,8 @@ ebtablesCreateRuleInstance(char chainPre } virBufferAsprintf(buf, - CMD_DEF_PRE %s -t %s -%%c %s %%s, - ebtables_cmd_path, EBTABLES_DEFAULT_TABLE, chain); + CMD_DEF_PRE $EBT -t nat -%%c %s %%s, + chain); if (ebtablesHandleEthHdr(buf, @@ -2120,8 +2120,8 @@ ebtablesCreateRuleInstance(char chainPre case VIR_NWFILTER_RULE_PROTOCOL_RARP: virBufferAsprintf(buf, - CMD_DEF_PRE %s -t %s -%%c %s %%s, - ebtables_cmd_path, EBTABLES_DEFAULT_TABLE, chain); + CMD_DEF_PRE $EBT -t nat -%%c %s %%s, + chain); if (ebtablesHandleEthHdr(buf, vars, @@ -2229,8 +2229,8 @@ ebtablesCreateRuleInstance(char chainPre case VIR_NWFILTER_RULE_PROTOCOL_IP: virBufferAsprintf(buf, - CMD_DEF_PRE %s -t %s -%%c %s %%s, - ebtables_cmd_path, EBTABLES_DEFAULT_TABLE, chain); + CMD_DEF_PRE $EBT -t nat -%%c %s %%s, + chain); if (ebtablesHandleEthHdr(buf, vars, @@ -2365,8 +2365,8 @@ ebtablesCreateRuleInstance(char chainPre case VIR_NWFILTER_RULE_PROTOCOL_IPV6: virBufferAsprintf(buf, - CMD_DEF_PRE %s -t %s -%%c %s %%s, - ebtables_cmd_path, EBTABLES_DEFAULT_TABLE,
[libvirt] problem with nwfilter and ip6tables
Hi, I'm investigating using the nwfilter-functionality of libvirt to give my clients the possibility to block ports of their VPSes. The same mechanism allows me to restrict the outgoing traffic a VPS is generating. In the end, I want to restrict MAC, IPv4 and IPv6 traffic, while the client can also restrict traffic to UDP and TCP. All goes well, until I want to restrict the UDP/TCP traffic to certain IPv6 addresses. Where iptables shows the IPv4-restriction I've put up, ip6tables doesn't show anything. In the logs, I only see some ip6tables -D, -X and -F commands failing, which is expected when libvirt tries to delete/flush rules that were never there. I've built my nwfilter containing the following IPv6-rules, which I for instance reference once for all the TCP-ports which should be open. !-- Allow established traffic -- filter name='ipv6-allow-statefull' chain='ipv6' rule action='accept' direction='in' priority='500' all state='ESTABLISHED'/ /rule rule action='accept' direction='out' priority='500' all state='ESTABLISHED,RELATED'/ /rule /filter !-- Allow TCP in $PORT -- filter name='ipv6-allow-create-state-by-port' chain='ipv6' rule action='accept' direction='in' priority='500' tcp state='NEW' dstportstart='$PORT'/ /rule rule action='accept' direction='in' priority='500' udp state='NEW' dstportstart='$PORT'/ /rule /filter !-- Allow IPv6 traffic from $RANGE -- filter name='ipv6-allow-create-state-by-range' chain='ipv6' rule action='accept' direction='out' priority='500' ipv6 srcipaddr='$RANGE' srcipmask='64'/ /rule /filter !-- Drop all other IPv6 traffic -- filter name='ipv6-drop-stateless' chain='ipv6' rule action='drop' direction='inout' priority='999' all/ /rule /filter I use a similar approach for my IPv4 firewall, and it works perfectly. When I use these IPv6 rules, all IPv6 traffic is apparently dropped, but it's hard to debug when the result of this config is abscent in ip6tables. I'm using these version of software on debian 6.0 squeeze: virsh # version Compiled against library: libvir 0.9.2 Using library: libvir 0.9.2 Using API: QEMU 0.9.2 Running hypervisor: QEMU 0.15.0 Does anyone have any clues? Thanks in advance! Regards, Reinier Schoof -- TransIP BV | https://www.transip.nl/ -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] qemu: Copy console definition from serial
On 17.11.2011 00:33, Eric Blake wrote: On 11/16/2011 06:14 AM, Michal Privoznik wrote: Now, when we support multiple consoles per domain, the vm-def-console[0] can still remain an alias for vm-def-serial[0]; However, we need to copy it's source definition as well otherwise we'll regress on virDomainOpenConsole. --- src/conf/domain_conf.c | 72 ++ src/conf/domain_conf.h |2 + src/libvirt_private.syms |1 + src/qemu/qemu_process.c | 19 +-- 4 files changed, 90 insertions(+), 4 deletions(-) ACK if you squash this in to avoid the memory leak (you may want to wait for Dave to confirm that squashing this in still works in his testing): It works for me with squashed part. The 'reproducer' is really simple - just run 'virsh console $vm' where vm has console defined like this: domain type='kvm' ... devices ... serial type='pty' target port='0'/ /serial console type='pty' target type='serial' port='0'/ /console ... /devices /domain I assume it works for Dave as well; so I am pushing it. Thanks Michal -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [TCK][PATCH] add more test cases
On 11/21/2011 08:21 AM, Daniel P. Berrange wrote: On Mon, Nov 21, 2011 at 07:40:14AM -0500, Stefan Berger wrote: This patch adds a couple more test cases (especially for IPv6 configurations) to the network test 100. Again make sure that some of the parameters from tck-testnet's XML have made it into command line parameters of dnsmasq. --- scripts/networks/networkxml2hostout/tck-testnet-3.dat | 49 + scripts/networks/networkxml2hostout/tck-testnet-3.post.dat | 19 + scripts/networks/networkxml2xmlin/tck-testnet-3.xml| 22 + 3 files changed, 90 insertions(+) ACK Daniel Pushed -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [TCK] [PATCH] nwfilter: Add '-n' flag to iptables command where missing
On 11/21/2011 08:18 AM, Daniel P. Berrange wrote: On Mon, Nov 21, 2011 at 07:20:28AM -0500, Stefan Berger wrote: Add the -n flag to the iptables command where it is missing to avoid delays due to name resolution. --- scripts/nwfilter/nwfilterxml2fwallout/all-test.fwall |9 + scripts/nwfilter/nwfilterxml2fwallout/target-test.fwall |8 scripts/nwfilter/nwfilterxml2fwallout/target-test2.fwall |8 3 files changed, 13 insertions(+), 12 deletions(-) ACK Daniel Pushed. Stefan -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [TCK] [PATCH] networks: Fix some errors in test 100
On 11/21/2011 08:19 AM, Daniel P. Berrange wrote: On Mon, Nov 21, 2011 at 07:26:18AM -0500, Stefan Berger wrote: Network test 100 when run via sh ./networkApplyTest.sh --tap-test --verbose --wait currently exhibits some problems. This patch fixes them. I now only looking for dnsmasq to be running with some of the parameters from tck-testnet having gone into its command line arguments. --- scripts/networks/networkxml2hostout/tck-testnet-1.dat | 10 ++ scripts/networks/networkxml2hostout/tck-testnet-1.post.dat |6 -- scripts/networks/networkxml2hostout/tck-testnet-2.dat | 10 ++ scripts/networks/networkxml2hostout/tck-testnet-2.post.dat |5 +++-- 4 files changed, 19 insertions(+), 12 deletions(-) ACK Daniel Pushed Stefan -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] bug: try to take disk snapshot for LVM2 Volume
On 2011-11-21 9:51, MATSUDA, Daiki wrote: Sorry, I confirmed the snapshot file is not wrong. I moved the snapshot file created under /dev as /dev/VG1/abc.xx to other place and fixed the config file re-writed by libvirt to use moved snapshot file abc.xx. So, the domain starts with no problem. Regards MATSUDA Daiki So the abc.xx is a plain image file instead of a LVM block device. I was wondering why the plain file was allowed to be created on a devfs file system. On 11/15/2011 08:20 PM, Dave Allan wrote: After working on this some more, I think that identifying problematic file systems, like devtmpfs, is too tricky to be portable. But I think we can meet halfway - right now, the libvirt code blindly generates a filename if one was not provided, regardless of the file type of the backing file it will be wrapping. But maybe it would be sufficient to make the command error out if no qcow2 filename is provided and the backing file is not a regular file. As in this patch: Ok, now I understand the situation; thanks to everyone for the explanations. I'm somewhat uncomfortable using file type as a proxy for troublesome filesystem since although they are linked in this case, I'm not sure they're linked in all cases. Maybe I'm wrong about that. If there is no portable way to determine whether a particular filesystem is going to be a problem, I would just clearly document the limitations of letting libvirt choose the filename and the importance of not using that functionality on filesystems that cannot hold a useful snapshot. My patch would not be preventing snapshots of block devices, but merely requiring that the user supply the qcow2 filename that will wrap the block device. The problem with just documenting the issue is that someone will fail to read the documentation, perform a default snapshot that creates a problematic qcow2 file, then be upset that their domain fails to boot and that they lost all the changes made since the snapshot. I'm still in favor of this patch if anyone else thinks it is worthwhile. Subject: [PATCH] snapshot: refuse to generate names for non-regular backing files For whatever reason, the kernel allows you to create a regular file named /dev/sdc.12345; although this file will disappear the next time devtmpfs is remounted. If you let libvirt generate the name of the external snapshot for a disk image originally using the block device /dev/sdc, then the domain will be rendered unbootable once the qcow2 file is lost on the next devtmpfs remount. In this case, the user should have used 'virsh snapshot-create --xmlfile' or 'virsh snapshot-create-as --diskspec' to specify the name for the qcow2 file in a sane location, rather than relying on libvirt generating a name that is most likely to be wrong. We can help avoid naive mistakes by enforcing that the user provide the external name for any backing file that is not a regular file. * src/conf/domain_conf.c (virDomainSnapshotAlignDisks): Only generate names if backing file exists as regular file. Reported by MATSUDA Daiki. -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] problem with nwfilter and ip6tables
On 11/21/2011 08:46 AM, Reinier Schoof wrote: Hi, I'm investigating using the nwfilter-functionality of libvirt to give my clients the possibility to block ports of their VPSes. The same mechanism allows me to restrict the outgoing traffic a VPS is generating. In the end, I want to restrict MAC, IPv4 and IPv6 traffic, while the client can also restrict traffic to UDP and TCP. All goes well, until I want to restrict the UDP/TCP traffic to certain IPv6 addresses. Where iptables shows the IPv4-restriction I've put up, ip6tables doesn't show anything. In the logs, I only see some ip6tables -D, -X and -F commands failing, which is expected when libvirt tries to delete/flush rules that were never there. I've built my nwfilter containing the following IPv6-rules, which I for instance reference once for all the TCP-ports which should be open. !-- Allow established traffic -- filter name='ipv6-allow-statefull' chain='ipv6' rule action='accept' direction='in' priority='500' all state='ESTABLISHED'/ /rule rule action='accept' direction='out' priority='500' all state='ESTABLISHED,RELATED'/ /rule /filter With the configuration as you have it, can you post the dump of ip6tables -L -n ? Can you put the two rules above on priority '100'. !-- Allow TCP in $PORT -- filter name='ipv6-allow-create-state-by-port' chain='ipv6' rule action='accept' direction='in' priority='500' tcp state='NEW' dstportstart='$PORT'/ /rule rule action='accept' direction='in' priority='500' udp state='NEW' dstportstart='$PORT'/ /rule /filter !-- Allow IPv6 traffic from $RANGE -- filter name='ipv6-allow-create-state-by-range' chain='ipv6' rule action='accept' direction='out' priority='500' ipv6 srcipaddr='$RANGE' srcipmask='64'/ /rule /filter Can you put this one in priority '600'? !-- Drop all other IPv6 traffic -- filter name='ipv6-drop-stateless' chain='ipv6' rule action='drop' direction='inout' priority='999' all/ /rule /filter With the above comments 'implemented', does it 'work'? If not: - I'd be curious about the content of $RANGE that you're passing in. - how does the filter look like that ties all the above filters together. The order in which the above filters are referenced matters as long as you keep the rules at priority '500'. It should work with ipv6 as well as it does for ipv4, but I must say that I don't really test with IPv6 much... Stefan I use a similar approach for my IPv4 firewall, and it works perfectly. When I use these IPv6 rules, all IPv6 traffic is apparently dropped, but it's hard to debug when the result of this config is abscent in ip6tables. I'm using these version of software on debian 6.0 squeeze: virsh # version Compiled against library: libvir 0.9.2 Using library: libvir 0.9.2 Using API: QEMU 0.9.2 Running hypervisor: QEMU 0.15.0 Does anyone have any clues? Thanks in advance! Regards, Reinier Schoof -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] problem with nwfilter and ip6tables
Hi Stefan, thanks for your quick response Op 21-11-2011 15:21, Stefan Berger schreef: On 11/21/2011 08:46 AM, Reinier Schoof wrote: Hi, I'm investigating using the nwfilter-functionality of libvirt to give my clients the possibility to block ports of their VPSes. The same mechanism allows me to restrict the outgoing traffic a VPS is generating. In the end, I want to restrict MAC, IPv4 and IPv6 traffic, while the client can also restrict traffic to UDP and TCP. All goes well, until I want to restrict the UDP/TCP traffic to certain IPv6 addresses. Where iptables shows the IPv4-restriction I've put up, ip6tables doesn't show anything. In the logs, I only see some ip6tables -D, -X and -F commands failing, which is expected when libvirt tries to delete/flush rules that were never there. I've built my nwfilter containing the following IPv6-rules, which I for instance reference once for all the TCP-ports which should be open. !-- Allow established traffic -- filter name='ipv6-allow-statefull' chain='ipv6' rule action='accept' direction='in' priority='500' all state='ESTABLISHED'/ /rule rule action='accept' direction='out' priority='500' all state='ESTABLISHED,RELATED'/ /rule /filter With the configuration as you have it, can you post the dump of ip6tables -L -n ? Nothing to see there. All I see in my libvirt.log is some ip6tables -D, -X, -F and -E commands failing: /sbin/ip6tables -D libvirt-out -m physdev --physdev-out vpsif3 -g FO-vpsif3 /sbin/ip6tables -D libvirt-in -m physdev --physdev-in vpsif3 -g FI-vpsif3 /sbin/ip6tables -D libvirt-host-in -m physdev --physdev-in vpsif3 -g HI-vpsif3 [...] Command stderr: ip6tables v1.4.12: goto 'FO-vpsif3' is not a chain Try `ip6tables -h' or 'ip6tables --help' for more information. ip6tables v1.4.12: goto 'FI-vpsif3' is not a chain Try `ip6tables -h' or 'ip6tables --help' for more information. ip6tables v1.4.12: goto 'HI-vpsif3' is not a chain Try `ip6tables -h' or 'ip6tables --help' for more information. [...] Can you put the two rules above on priority '100'. !-- Allow TCP in $PORT -- filter name='ipv6-allow-create-state-by-port' chain='ipv6' rule action='accept' direction='in' priority='500' tcp state='NEW' dstportstart='$PORT'/ /rule rule action='accept' direction='in' priority='500' udp state='NEW' dstportstart='$PORT'/ /rule /filter !-- Allow IPv6 traffic from $RANGE -- filter name='ipv6-allow-create-state-by-range' chain='ipv6' rule action='accept' direction='out' priority='500' ipv6 srcipaddr='$RANGE' srcipmask='64'/ /rule /filter Can you put this one in priority '600'? !-- Drop all other IPv6 traffic -- filter name='ipv6-drop-stateless' chain='ipv6' rule action='drop' direction='inout' priority='999' all/ /rule /filter With the above comments 'implemented', does it 'work'? Doesn't change a thing. If not: - I'd be curious about the content of $RANGE that you're passing in. parameter name='RANGE' value='2a01:7c8::5::'/ - how does the filter look like that ties all the above filters together. The order in which the above filters are referenced matters as long as you keep the rules at priority '500'. The filters are referenced in the exact order as I pasted them. This is the same as with the IPv4-version of the ruleset. It should work with ipv6 as well as it does for ipv4, but I must say that I don't really test with IPv6 much... Stefan I use a similar approach for my IPv4 firewall, and it works perfectly. When I use these IPv6 rules, all IPv6 traffic is apparently dropped, but it's hard to debug when the result of this config is abscent in ip6tables. I'm using these version of software on debian 6.0 squeeze: virsh # version Compiled against library: libvir 0.9.2 Using library: libvir 0.9.2 Using API: QEMU 0.9.2 Running hypervisor: QEMU 0.15.0 Does anyone have any clues? Thanks in advance! Regards, Reinier Schoof -- TransIP BV | https://www.transip.nl/ -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] qemu: Copy console definition from serial
On Mon, Nov 21, 2011 at 02:52:21PM +0100, Michal Privoznik wrote: On 17.11.2011 00:33, Eric Blake wrote: On 11/16/2011 06:14 AM, Michal Privoznik wrote: Now, when we support multiple consoles per domain, the vm-def-console[0] can still remain an alias for vm-def-serial[0]; However, we need to copy it's source definition as well otherwise we'll regress on virDomainOpenConsole. --- src/conf/domain_conf.c | 72 ++ src/conf/domain_conf.h |2 + src/libvirt_private.syms |1 + src/qemu/qemu_process.c | 19 +-- 4 files changed, 90 insertions(+), 4 deletions(-) ACK if you squash this in to avoid the memory leak (you may want to wait for Dave to confirm that squashing this in still works in his testing): It works for me with squashed part. The 'reproducer' is really simple - just run 'virsh console $vm' where vm has console defined like this: domain type='kvm' ... devices ... serial type='pty' target port='0'/ /serial console type='pty' target type='serial' port='0'/ /console ... /devices /domain I assume it works for Dave as well; so I am pushing it. Confirmed, it still works for me. Dave -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] Fix build on Mingw32 wrt export of virNetServerGetDBusConn
On 11/21/2011 04:47 AM, Daniel P. Berrange wrote: From: Daniel P. Berrange berra...@redhat.com Mingw32 complains if you request export of a symbol which does not in fact exist. * src/libvirt_bridge.syms, src/libvirt_macvtap.syms: Delete obsolete files * src/libvirt_private.syms: Remove virNetServerGetDBusConn * src/libvirt_dbus.syms: Add virNetServerGetDBusConn ACK. -- Eric Blake ebl...@redhat.com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] problem with nwfilter and ip6tables
On 11/21/2011 08:46 AM, Reinier Schoof wrote: Going back to the original email: Hi, I'm investigating using the nwfilter-functionality of libvirt to give my clients the possibility to block ports of their VPSes. The same mechanism allows me to restrict the outgoing traffic a VPS is generating. In the end, I want to restrict MAC, IPv4 and IPv6 traffic, while the client can also restrict traffic to UDP and TCP. All goes well, until I want to restrict the UDP/TCP traffic to certain IPv6 addresses. Where iptables shows the IPv4-restriction I've put up, ip6tables doesn't show anything. In the logs, I only see some ip6tables -D, -X and -F commands failing, which is expected when libvirt tries to delete/flush rules that were never there. I've built my nwfilter containing the following IPv6-rules, which I for instance reference once for all the TCP-ports which should be open. !-- Allow established traffic -- filter name='ipv6-allow-statefull' chain='ipv6' rule action='accept' direction='in' priority='500' all state='ESTABLISHED'/ /rule rule action='accept' direction='out' priority='500' all state='ESTABLISHED,RELATED'/ /rule /filter Replace with filter name='ipv6-allow-statefull' chain='root' uuidd7ca42fe-a2f5-6491-cdee-10d8a0956772/uuid rule action='accept' direction='in' priority='100' all-ipv6 state='ESTABLISHED'/ /rule rule action='accept' direction='out' priority='100' all-ipv6 state='ESTABLISHED,RELATED'/ /rule /filter !-- Allow TCP in $PORT -- filter name='ipv6-allow-create-state-by-port' chain='ipv6' rule action='accept' direction='in' priority='500' tcp state='NEW' dstportstart='$PORT'/ /rule rule action='accept' direction='in' priority='500' udp state='NEW' dstportstart='$PORT'/ /rule /filter Replace with filter name='ipv6-allow-create-state-by-port' chain='root' uuidff97e825-712d-6b1a-c5d1-46fe635f9dd6/uuid rule action='accept' direction='in' priority='500' tcp-ipv6 state='NEW' dstportstart='$PORT'/ /rule rule action='accept' direction='in' priority='500' udp-ipv6 state='NEW' dstportstart='$PORT'/ /rule /filter !-- Allow IPv6 traffic from $RANGE -- filter name='ipv6-allow-create-state-by-range' chain='ipv6' rule action='accept' direction='out' priority='500' ipv6 srcipaddr='$RANGE' srcipmask='64'/ /rule /filter This probably should either be direction='in' or you may want to replace srcipaddr and srcipmask with dstipaddr and dstipmask. Replace with filter name='ipv6-allow-create-state-by-range' chain='root' uuid6e738070-9505-730d-14e6-ee01a6eb5885/uuid rule action='accept' direction='in' priority='500' all-ipv6 srcipaddr='$RANGE' srcipmask='62'/ /rule /filter You may want to add state='NEW' to the rule as well. !-- Drop all other IPv6 traffic -- filter name='ipv6-drop-stateless' chain='ipv6' rule action='drop' direction='inout' priority='999' all/ /rule /filter Replace with filter name='ipv6-drop-stateless' chain='root' uuid4377aca7-18fb-b373-4462-4ee2ba3db7cd/uuid rule action='drop' direction='inout' priority='999' all-ipv6/ /rule /filter You have to change the chain to 'root' and the protocol in the rules has to be tcp-ipv6, all-ipv6 etc. for ipv6 traffic. The reason is that most of these rules could be applied to either iptables or ip6tables and the network filtering system needs some more 'hints' whether it is indeed an ipv6 rule so it create ip6tables commands versus iptables commands. I hope this helps. 'ip6tables -L -n' here now shows: Chain FI-vnet0 (1 references) target prot opt source destination RETURN all ::/0 ::/0state RELATED,ESTABLISHED RETURN all ::/0 ::/64 state ESTABLISHED ctdir ORIGINAL DROP all ::/0 ::/0 Chain FO-vnet0 (1 references) target prot opt source destination ACCEPT all ::/0 ::/0state ESTABLISHED ACCEPT tcp ::/0 ::/0tcp dpt:90 state NEW ACCEPT udp ::/0 ::/0udp dpt:90 state NEW ACCEPT all ::/64::/0state NEW,ESTABLISHED ctdir REPLY DROP all ::/0 ::/0 Chain HI-vnet0 (1 references) target prot opt source destination RETURN all ::/0 ::/0state RELATED,ESTABLISHED RETURN all ::/0 ::/64 state ESTABLISHED ctdir ORIGINAL DROP all ::/0 ::/0 Stefan I use a similar approach for my IPv4 firewall, and it works perfectly. When I use these IPv6 rules, all IPv6 traffic is apparently dropped, but it's hard to debug when the result of this config is abscent in ip6tables. I'm using these version of software on debian 6.0 squeeze: virsh # version Compiled against library: libvir 0.9.2 Using library: libvir 0.9.2 Using API: QEMU 0.9.2 Running hypervisor: QEMU 0.15.0
Re: [libvirt] [libvirt-glib] Add API to redefine an existing domain
Hi Hi Agreed with the comments from teuf + On Fri, Nov 18, 2011 at 8:24 PM, Zeeshan Ali (Khattak) zeesha...@gnome.org wrote: +void gvir_connection_redefine_domain(GVirConnection *conn, + GVirDomain *domain, + GVirConfigDomain *conf, + GError **err) +{ I would check that the given arguments are correct, != NULL or GVIR_IS_FOO. I would return TRUE on success, and error can be NULL (regular glib convention) + const gchar *xml; + virDomainPtr handle; + GVirDomain *dom; + virDomainPtr dom_handle; + GVirConnectionPrivate *priv = conn-priv; + + xml = gvir_config_object_to_xml(GVIR_CONFIG_OBJECT(conf)); + + g_return_if_fail(xml != NULL); + + g_mutex_lock(priv-lock); + dom = g_hash_table_lookup (priv-domains, + (gpointer)gvir_domain_get_uuid(domain)); + g_mutex_unlock(priv-lock); + g_return_if_fail(dom != NULL); + /* FIXME: Check if config's domain ID is the same as domain passed */ I suppose this is missing Christophe gconfig patches. + if (!(handle = virDomainDefineXML(priv-conn, xml))) { + *err = gvir_error_new_literal(GVIR_CONNECTION_ERROR, + 0, + Failed to redefine domain); + return NULL; + } +} And I would verify that handle is == to current domain handle. If not, we probably need to replace it or we need to throw an error. At the minimum it would be nice to leave a comment after verifying that it is safe to ignore return value. (then send an updated patch for ack) regards -- Marc-André Lureau -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [libvirt-glib 11/37] Implement gvir_config_os_set_os_type
Hey, On Tue, Nov 15, 2011 at 03:33:45PM +0100, Marc-André Lureau wrote: However, thinking a bit more about it, genum_get_nick() shouldn't warn if given a value that has no associated nick, because enums shouldn't be limited to their associated name, and those value would be perfectly valid, but should return NULL and that's it. For now I have added a warning to genum_get_nick since we shouldn't get an enum with no associated strings. If this happens, this means something unexpected happened, so it's better to warn about it. We can change this when we have a valid use case for this. However, siliently not doing anything is misleading. So instead of if (type_str != NULL) xmlNodeSetContent(node, (xmlChar*)type_str); I would do (or similar): g_return_if_fail (type_str != NULL); xmlNodeSetContent(node, (xmlChar*)type_str); And I did that change too. Christophe pgptF48IGHHgQ.pgp Description: PGP signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] libvirt-gconfig patches
Hi, This is the 2nd version of my libvirt-gconfig patches. I think I have addressed all of the issues that were raised (or told why I didn't address them). If I missed anything, just let me know. Some of the patches have been split/merged after the review so the series look a bit different from the first one even if the content is the same. One notable change is that I dropped the chardev classes for now since I need to go back to the drawing board a bit for these Christophe -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-gconfig PATCHv2 03/32] Make some GVirConfigObject helpers private
At this point, I'm not sure how/if the library user should be able to directly manipulate the XML data wrapped by a GVirConfigObject. It's preferrable to hide this API from the user until we have a clearer idea how to expose it. --- libvirt-gconfig/Makefile.am |3 +- libvirt-gconfig/libvirt-gconfig-domain.c |1 + libvirt-gconfig/libvirt-gconfig-object-private.h | 41 ++ libvirt-gconfig/libvirt-gconfig-object.c | 28 +-- libvirt-gconfig/libvirt-gconfig-object.h | 11 -- libvirt-gconfig/libvirt-gconfig.sym |1 - 6 files changed, 61 insertions(+), 24 deletions(-) create mode 100644 libvirt-gconfig/libvirt-gconfig-object-private.h diff --git a/libvirt-gconfig/Makefile.am b/libvirt-gconfig/Makefile.am index 0d15e78..52eff79 100644 --- a/libvirt-gconfig/Makefile.am +++ b/libvirt-gconfig/Makefile.am @@ -19,7 +19,8 @@ GCONFIG_HEADER_FILES = \ libvirt-gconfig-storage-pool.h \ libvirt-gconfig-storage-vol.h noinst_HEADERS = \ - libvirt-gconfig-helpers-private.h + libvirt-gconfig-helpers-private.h \ + libvirt-gconfig-object-private.h GCONFIG_SOURCE_FILES = \ libvirt-gconfig-object.c \ libvirt-gconfig-capabilities.c \ diff --git a/libvirt-gconfig/libvirt-gconfig-domain.c b/libvirt-gconfig/libvirt-gconfig-domain.c index 3290389..d971a95 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain.c +++ b/libvirt-gconfig/libvirt-gconfig-domain.c @@ -27,6 +27,7 @@ #include libvirt-gconfig/libvirt-gconfig.h #include libvirt-gconfig/libvirt-gconfig-helpers-private.h +#include libvirt-gconfig/libvirt-gconfig-object-private.h extern gboolean debugFlag; diff --git a/libvirt-gconfig/libvirt-gconfig-object-private.h b/libvirt-gconfig/libvirt-gconfig-object-private.h new file mode 100644 index 000..aec88bf --- /dev/null +++ b/libvirt-gconfig/libvirt-gconfig-object-private.h @@ -0,0 +1,41 @@ +/* + * libvirt-gconfig-config-object-private.h: base object for XML configuration + * + * Copyright (C) 2011 Red Hat + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: Christophe Fergeau cferg...@redhat.com + */ +#ifndef __LIBVIRT_GCONFIG_OBJECT_PRIVATE_H__ +#define __LIBVIRT_GCONFIG_OBJECT_PRIVATE_H__ + +G_BEGIN_DECLS + +xmlNodePtr gvir_config_object_get_xml_node(GVirConfigObject *config); +char *gvir_config_object_get_node_content(GVirConfigObject *object, + const char *node_name); +guint64 gvir_config_object_get_node_content_uint64(GVirConfigObject *object, + const char *node_name); +void gvir_config_object_set_node_content(GVirConfigObject *object, + const char *node_name, + const char *value); +void gvir_config_object_set_node_content_uint64(GVirConfigObject *object, +const char *node_name, +guint64 value); + +G_END_DECLS + +#endif /* __LIBVIRT_GCONFIG_OBJECT_H__ */ diff --git a/libvirt-gconfig/libvirt-gconfig-object.c b/libvirt-gconfig/libvirt-gconfig-object.c index fbdbedd..276be8c 100644 --- a/libvirt-gconfig/libvirt-gconfig-object.c +++ b/libvirt-gconfig/libvirt-gconfig-object.c @@ -29,6 +29,7 @@ #include libvirt-gconfig/libvirt-gconfig.h #include libvirt-gconfig/libvirt-gconfig-helpers-private.h +#include libvirt-gconfig/libvirt-gconfig-object-private.h //extern gboolean debugFlag; @@ -277,13 +278,15 @@ const gchar *gvir_config_object_get_schema(GVirConfigObject *config) /* FIXME: will we always have one xmlNode per GConfig object? */ /* FIXME: need to return the right node from subclasses */ /* NB: the xmlNodePtr must not be freed by the caller */ -xmlNodePtr gvir_config_object_get_xml_node(GVirConfigObject *config) +G_GNUC_INTERNAL xmlNodePtr +gvir_config_object_get_xml_node(GVirConfigObject *config) { return config-priv-node; } -char *gvir_config_object_get_node_content(GVirConfigObject *object, - const char *node_name)
[libvirt] [libvirt-gconfig PATCHv2 10/32] Add gvir_config_genum_get_nick helper
We will often need to convert from an enum to its string representation, add an helper for that to avoid duplicating that code. -- v2: moved before gvir_config_clock_set_offset implementation since it needs it --- libvirt-gconfig/libvirt-gconfig-helpers-private.h |1 + libvirt-gconfig/libvirt-gconfig-helpers.c | 17 + 2 files changed, 18 insertions(+), 0 deletions(-) diff --git a/libvirt-gconfig/libvirt-gconfig-helpers-private.h b/libvirt-gconfig/libvirt-gconfig-helpers-private.h index c7a5d6a..59efd24 100644 --- a/libvirt-gconfig/libvirt-gconfig-helpers-private.h +++ b/libvirt-gconfig/libvirt-gconfig-helpers-private.h @@ -40,6 +40,7 @@ xmlChar * gvir_config_xml_get_child_element_content (xmlNode *node, const char *child_name); char *gvir_config_xml_get_child_element_content_glib (xmlNode*node, const char *child_name); +const char *gvir_config_genum_get_nick (GType enum_type, gint value); G_END_DECLS #endif /* __LIBVIRT_GCONFIG_HELPERS_PRIVATE_H__ */ diff --git a/libvirt-gconfig/libvirt-gconfig-helpers.c b/libvirt-gconfig/libvirt-gconfig-helpers.c index 2e28429..d7e1140 100644 --- a/libvirt-gconfig/libvirt-gconfig-helpers.c +++ b/libvirt-gconfig/libvirt-gconfig-helpers.c @@ -178,3 +178,20 @@ gvir_config_xml_get_child_element_content_glib (xmlNode *node, return copy; } + +const char *gvir_config_genum_get_nick (GType enum_type, gint value) +{ +GEnumClass *enum_class; +GEnumValue *enum_value; + +g_return_val_if_fail (G_TYPE_IS_ENUM (enum_type), NULL); + +enum_class = g_type_class_ref(enum_type); +enum_value = g_enum_get_value(enum_class, value); +g_type_class_unref(enum_class); + +if (enum_value != NULL) +return enum_value-value_nick; + +g_return_val_if_reached(NULL); +} -- 1.7.7.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-gconfig PATCHv2 01/32] Remove unneeded blank line in *_class_init
--- libvirt-gconfig/libvirt-gconfig-capabilities.c|1 - libvirt-gconfig/libvirt-gconfig-domain-snapshot.c |1 - libvirt-gconfig/libvirt-gconfig-interface.c |1 - libvirt-gconfig/libvirt-gconfig-network-filter.c |1 - libvirt-gconfig/libvirt-gconfig-network.c |1 - libvirt-gconfig/libvirt-gconfig-node-device.c |1 - libvirt-gconfig/libvirt-gconfig-secret.c |1 - libvirt-gconfig/libvirt-gconfig-storage-pool.c|1 - libvirt-gconfig/libvirt-gconfig-storage-vol.c |1 - 9 files changed, 0 insertions(+), 9 deletions(-) diff --git a/libvirt-gconfig/libvirt-gconfig-capabilities.c b/libvirt-gconfig/libvirt-gconfig-capabilities.c index 2f79073..55b196b 100644 --- a/libvirt-gconfig/libvirt-gconfig-capabilities.c +++ b/libvirt-gconfig/libvirt-gconfig-capabilities.c @@ -44,7 +44,6 @@ G_DEFINE_TYPE(GVirConfigCapabilities, gvir_config_capabilities, GVIR_TYPE_CONFIG static void gvir_config_capabilities_class_init(GVirConfigCapabilitiesClass *klass) { - g_type_class_add_private(klass, sizeof(GVirConfigCapabilitiesPrivate)); } diff --git a/libvirt-gconfig/libvirt-gconfig-domain-snapshot.c b/libvirt-gconfig/libvirt-gconfig-domain-snapshot.c index e7dc36e..aa74254 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain-snapshot.c +++ b/libvirt-gconfig/libvirt-gconfig-domain-snapshot.c @@ -44,7 +44,6 @@ G_DEFINE_TYPE(GVirConfigDomainSnapshot, gvir_config_domain_snapshot, GVIR_TYPE_C static void gvir_config_domain_snapshot_class_init(GVirConfigDomainSnapshotClass *klass) { - g_type_class_add_private(klass, sizeof(GVirConfigDomainSnapshotPrivate)); } diff --git a/libvirt-gconfig/libvirt-gconfig-interface.c b/libvirt-gconfig/libvirt-gconfig-interface.c index 5e934f6..b58a4b4 100644 --- a/libvirt-gconfig/libvirt-gconfig-interface.c +++ b/libvirt-gconfig/libvirt-gconfig-interface.c @@ -44,7 +44,6 @@ G_DEFINE_TYPE(GVirConfigInterface, gvir_config_interface, GVIR_TYPE_CONFIG_OBJEC static void gvir_config_interface_class_init(GVirConfigInterfaceClass *klass) { - g_type_class_add_private(klass, sizeof(GVirConfigInterfacePrivate)); } diff --git a/libvirt-gconfig/libvirt-gconfig-network-filter.c b/libvirt-gconfig/libvirt-gconfig-network-filter.c index 8b615bf..bea21a3 100644 --- a/libvirt-gconfig/libvirt-gconfig-network-filter.c +++ b/libvirt-gconfig/libvirt-gconfig-network-filter.c @@ -44,7 +44,6 @@ G_DEFINE_TYPE(GVirConfigNetworkFilter, gvir_config_network_filter, GVIR_TYPE_CON static void gvir_config_network_filter_class_init(GVirConfigNetworkFilterClass *klass) { - g_type_class_add_private(klass, sizeof(GVirConfigNetworkFilterPrivate)); } diff --git a/libvirt-gconfig/libvirt-gconfig-network.c b/libvirt-gconfig/libvirt-gconfig-network.c index 2bd2512..26d5d61 100644 --- a/libvirt-gconfig/libvirt-gconfig-network.c +++ b/libvirt-gconfig/libvirt-gconfig-network.c @@ -44,7 +44,6 @@ G_DEFINE_TYPE(GVirConfigNetwork, gvir_config_network, GVIR_TYPE_CONFIG_OBJECT); static void gvir_config_network_class_init(GVirConfigNetworkClass *klass) { - g_type_class_add_private(klass, sizeof(GVirConfigNetworkPrivate)); } diff --git a/libvirt-gconfig/libvirt-gconfig-node-device.c b/libvirt-gconfig/libvirt-gconfig-node-device.c index 3be973f..71389ef 100644 --- a/libvirt-gconfig/libvirt-gconfig-node-device.c +++ b/libvirt-gconfig/libvirt-gconfig-node-device.c @@ -44,7 +44,6 @@ G_DEFINE_TYPE(GVirConfigNodeDevice, gvir_config_node_device, GVIR_TYPE_CONFIG_OB static void gvir_config_node_device_class_init(GVirConfigNodeDeviceClass *klass) { - g_type_class_add_private(klass, sizeof(GVirConfigNodeDevicePrivate)); } diff --git a/libvirt-gconfig/libvirt-gconfig-secret.c b/libvirt-gconfig/libvirt-gconfig-secret.c index bb55c44..6267cf5 100644 --- a/libvirt-gconfig/libvirt-gconfig-secret.c +++ b/libvirt-gconfig/libvirt-gconfig-secret.c @@ -44,7 +44,6 @@ G_DEFINE_TYPE(GVirConfigSecret, gvir_config_secret, GVIR_TYPE_CONFIG_OBJECT); static void gvir_config_secret_class_init(GVirConfigSecretClass *klass) { - g_type_class_add_private(klass, sizeof(GVirConfigSecretPrivate)); } diff --git a/libvirt-gconfig/libvirt-gconfig-storage-pool.c b/libvirt-gconfig/libvirt-gconfig-storage-pool.c index 4cbda27..8a70ac2 100644 --- a/libvirt-gconfig/libvirt-gconfig-storage-pool.c +++ b/libvirt-gconfig/libvirt-gconfig-storage-pool.c @@ -44,7 +44,6 @@ G_DEFINE_TYPE(GVirConfigStoragePool, gvir_config_storage_pool, GVIR_TYPE_CONFIG_ static void gvir_config_storage_pool_class_init(GVirConfigStoragePoolClass *klass) { - g_type_class_add_private(klass, sizeof(GVirConfigStoragePoolPrivate)); } diff --git a/libvirt-gconfig/libvirt-gconfig-storage-vol.c b/libvirt-gconfig/libvirt-gconfig-storage-vol.c index e9e90be..4a17c45 100644 --- a/libvirt-gconfig/libvirt-gconfig-storage-vol.c +++ b/libvirt-gconfig/libvirt-gconfig-storage-vol.c @@ -44,7 +44,6 @@ G_DEFINE_TYPE(GVirConfigStorageVol, gvir_config_storage_vol,
[libvirt] [libvirt-gconfig PATCHv2 08/32] Add gvir_config_domain_set_clock
The implementation is likely to need to be completed later. We might want to store pointers from GVirConfigDomain to the associated GVirConfigClock, from GVirConfigClock to the GVirConfigDomain that contains it. Since I'm not sure yet if they will be needed, I chose to keep the implementation simple. -- v2: use g_return_if_fail to test function args for sanity --- libvirt-gconfig/libvirt-gconfig-domain.c | 12 libvirt-gconfig/libvirt-gconfig-domain.h |2 ++ libvirt-gconfig/libvirt-gconfig.sym |1 + 3 files changed, 15 insertions(+), 0 deletions(-) diff --git a/libvirt-gconfig/libvirt-gconfig-domain.c b/libvirt-gconfig/libvirt-gconfig-domain.c index 5db6bc4..4c4ca53 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain.c +++ b/libvirt-gconfig/libvirt-gconfig-domain.c @@ -237,3 +237,15 @@ void gvir_config_domain_set_features(GVirConfigDomain *domain, } g_object_notify(G_OBJECT(domain), features); } + +void gvir_config_domain_set_clock(GVirConfigDomain *domain, + GVirConfigClock *klock) +{ +xmlNodePtr clock_node; + +g_return_if_fail(GVIR_IS_CONFIG_DOMAIN(domain)); +g_return_if_fail(GVIR_IS_CONFIG_CLOCK(klock)); + +clock_node = gvir_config_object_get_xml_node(GVIR_CONFIG_OBJECT(klock)); +gvir_config_object_set_child(GVIR_CONFIG_OBJECT(domain), clock_node); +} diff --git a/libvirt-gconfig/libvirt-gconfig-domain.h b/libvirt-gconfig/libvirt-gconfig-domain.h index 6cc8f31..6f822cf 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain.h +++ b/libvirt-gconfig/libvirt-gconfig-domain.h @@ -69,6 +69,8 @@ void gvir_config_domain_set_memory(GVirConfigDomain *domain, guint64 memory); GStrv gvir_config_domain_get_features(GVirConfigDomain *domain); void gvir_config_domain_set_features(GVirConfigDomain *domain, const GStrv features); +void gvir_config_domain_set_clock(GVirConfigDomain *domain, + GVirConfigClock *klock); G_END_DECLS diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym index c3d46d5..7b346a1 100644 --- a/libvirt-gconfig/libvirt-gconfig.sym +++ b/libvirt-gconfig/libvirt-gconfig.sym @@ -13,6 +13,7 @@ LIBVIRT_GOBJECT_0.0.1 { gvir_config_domain_get_type; gvir_config_domain_new; gvir_config_domain_new_from_xml; + gvir_config_domain_set_clock; gvir_config_domain_get_features; gvir_config_domain_set_features; gvir_config_domain_get_memory; -- 1.7.7.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-gconfig PATCHv2 07/32] Add some GVirConfigClock setters
-- v2: use g_return_if_fail to test function args for sanity --- libvirt-gconfig/libvirt-gconfig-clock.c | 38 +++ libvirt-gconfig/libvirt-gconfig-clock.h |5 libvirt-gconfig/libvirt-gconfig.sym |2 + 3 files changed, 45 insertions(+), 0 deletions(-) diff --git a/libvirt-gconfig/libvirt-gconfig-clock.c b/libvirt-gconfig/libvirt-gconfig-clock.c index 1f28efb..25f6159 100644 --- a/libvirt-gconfig/libvirt-gconfig-clock.c +++ b/libvirt-gconfig/libvirt-gconfig-clock.c @@ -27,6 +27,7 @@ #include libxml/tree.h #include libvirt-gconfig/libvirt-gconfig.h +#include libvirt-gconfig/libvirt-gconfig-object-private.h extern gboolean debugFlag; @@ -79,3 +80,40 @@ GVirConfigClock *gvir_config_clock_new_from_xml(const gchar *xml, clock, NULL, xml, error); return GVIR_CONFIG_CLOCK(object); } + +void gvir_config_clock_set_timezone(GVirConfigClock *klock, +const char *tz) +{ +xmlNodePtr node; +xmlChar *encoded_tz; + +g_return_if_fail(GVIR_IS_CONFIG_CLOCK(klock)); +g_return_if_fail(tz != NULL); + +node = gvir_config_object_get_xml_node(GVIR_CONFIG_OBJECT(klock)); +if (node == NULL) +return; + +xmlNewProp(node, (xmlChar*)offset, (xmlChar*)timezone); +encoded_tz = xmlEncodeEntitiesReentrant(node-doc, (xmlChar*)tz); +xmlNewProp(node, (xmlChar*)timezone, encoded_tz); +xmlFree(encoded_tz); +} + +void gvir_config_clock_set_variable_offset(GVirConfigClock *klock, + gint seconds) +{ +xmlNodePtr node; +char *offset_str; + +g_return_if_fail(GVIR_IS_CONFIG_CLOCK(klock)); + +node = gvir_config_object_replace_child(GVIR_CONFIG_OBJECT(klock), clock); +if (node == NULL) +return; + +xmlNewProp(node, (xmlChar*)offset, (xmlChar*)variable); +offset_str = g_strdup_printf(%d, seconds); +xmlNewProp(node, (xmlChar*)timezone, (xmlChar*)offset_str); +g_free(offset_str); +} diff --git a/libvirt-gconfig/libvirt-gconfig-clock.h b/libvirt-gconfig/libvirt-gconfig-clock.h index fc8850a..26f4b53 100644 --- a/libvirt-gconfig/libvirt-gconfig-clock.h +++ b/libvirt-gconfig/libvirt-gconfig-clock.h @@ -63,6 +63,11 @@ GVirConfigClock *gvir_config_clock_new(void); GVirConfigClock *gvir_config_clock_new_from_xml(const gchar *xml, GError **error); +void gvir_config_clock_set_timezone(GVirConfigClock *klock, +const char *tz); +void gvir_config_clock_set_variable_offset(GVirConfigClock *klock, + gint seconds); + G_END_DECLS #endif /* __LIBVIRT_GCONFIG_CLOCK_H__ */ diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym index a01c22d..c3d46d5 100644 --- a/libvirt-gconfig/libvirt-gconfig.sym +++ b/libvirt-gconfig/libvirt-gconfig.sym @@ -7,6 +7,8 @@ LIBVIRT_GOBJECT_0.0.1 { gvir_config_clock_get_type; gvir_config_clock_new; gvir_config_clock_new_from_xml; + gvir_config_clock_set_timezone; + gvir_config_clock_set_variable_offset; gvir_config_domain_get_type; gvir_config_domain_new; -- 1.7.7.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-gconfig PATCHv2 02/32] Remove unused prototype for gvir_config_object_parse
There is no corresponding implementation so no need to keep this prototype. --- libvirt-gconfig/libvirt-gconfig-object.h |3 --- 1 files changed, 0 insertions(+), 3 deletions(-) diff --git a/libvirt-gconfig/libvirt-gconfig-object.h b/libvirt-gconfig/libvirt-gconfig-object.h index 52e4525..bac3403 100644 --- a/libvirt-gconfig/libvirt-gconfig-object.h +++ b/libvirt-gconfig/libvirt-gconfig-object.h @@ -85,9 +85,6 @@ void gvir_config_object_set_node_content_uint64(GVirConfigObject *object, const char *node_name, guint64 value); -/* FIXME: move to a libvirt-gconfig-helpers.h file? */ -xmlNodePtr gvir_config_object_parse(const char *xml, const char *root_node, GError **err); - G_END_DECLS #endif /* __LIBVIRT_GCONFIG_OBJECT_H__ */ -- 1.7.7.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-gconfig PATCHv2 11/32] Implement gvir_config_clock_set_offset
-- v2: use gvir_config_genum_get_nick helper since it's now added before this commit use g_return_if_fail to test function args for sanity --- libvirt-gconfig/libvirt-gconfig-clock.c | 17 + libvirt-gconfig/libvirt-gconfig-clock.h |8 libvirt-gconfig/libvirt-gconfig.sym |2 ++ 3 files changed, 27 insertions(+), 0 deletions(-) diff --git a/libvirt-gconfig/libvirt-gconfig-clock.c b/libvirt-gconfig/libvirt-gconfig-clock.c index 25f6159..0768e58 100644 --- a/libvirt-gconfig/libvirt-gconfig-clock.c +++ b/libvirt-gconfig/libvirt-gconfig-clock.c @@ -27,6 +27,7 @@ #include libxml/tree.h #include libvirt-gconfig/libvirt-gconfig.h +#include libvirt-gconfig/libvirt-gconfig-helpers-private.h #include libvirt-gconfig/libvirt-gconfig-object-private.h extern gboolean debugFlag; @@ -81,6 +82,22 @@ GVirConfigClock *gvir_config_clock_new_from_xml(const gchar *xml, return GVIR_CONFIG_CLOCK(object); } +void gvir_config_clock_set_offset(GVirConfigClock *klock, + GVirConfigClockOffset offset) +{ +xmlNodePtr node; +const char *offset_str; + +g_return_if_fail(GVIR_IS_CONFIG_CLOCK(klock)); + +node = gvir_config_object_get_xml_node(GVIR_CONFIG_OBJECT(klock)); +g_return_if_fail(node != NULL); +offset_str = gvir_config_genum_get_nick(GVIR_TYPE_CONFIG_CLOCK_OFFSET, + offset); +g_return_if_fail(offset_str != NULL); +xmlNewProp(node, (xmlChar*)offset, (xmlChar*)offset_str); +} + void gvir_config_clock_set_timezone(GVirConfigClock *klock, const char *tz) { diff --git a/libvirt-gconfig/libvirt-gconfig-clock.h b/libvirt-gconfig/libvirt-gconfig-clock.h index 26f4b53..49cacef 100644 --- a/libvirt-gconfig/libvirt-gconfig-clock.h +++ b/libvirt-gconfig/libvirt-gconfig-clock.h @@ -56,6 +56,12 @@ struct _GVirConfigClockClass gpointer padding[20]; }; +typedef enum { +GVIR_CONFIG_CLOCK_UTC, +GVIR_CONFIG_CLOCK_LOCALTIME, +GVIR_CONFIG_CLOCK_TIMEZONE, +GVIR_CONFIG_CLOCK_VARIABLE +} GVirConfigClockOffset; GType gvir_config_clock_get_type(void); @@ -63,6 +69,8 @@ GVirConfigClock *gvir_config_clock_new(void); GVirConfigClock *gvir_config_clock_new_from_xml(const gchar *xml, GError **error); +void gvir_config_clock_set_offset(GVirConfigClock *klock, + GVirConfigClockOffset offset); void gvir_config_clock_set_timezone(GVirConfigClock *klock, const char *tz); void gvir_config_clock_set_variable_offset(GVirConfigClock *klock, diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym index 7b346a1..0b60c7c 100644 --- a/libvirt-gconfig/libvirt-gconfig.sym +++ b/libvirt-gconfig/libvirt-gconfig.sym @@ -5,8 +5,10 @@ LIBVIRT_GOBJECT_0.0.1 { gvir_config_capabilities_new_from_xml; gvir_config_clock_get_type; + gvir_config_clock_offset_get_type; gvir_config_clock_new; gvir_config_clock_new_from_xml; + gvir_config_clock_set_offset; gvir_config_clock_set_timezone; gvir_config_clock_set_variable_offset; -- 1.7.7.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-gconfig PATCHv2 06/32] Add gobject boilerplate for GVirConfigClock and GVirConfigTimer
--- libvirt-gconfig/Makefile.am |4 ++ libvirt-gconfig/libvirt-gconfig-clock.c | 81 +++ libvirt-gconfig/libvirt-gconfig-clock.h | 68 ++ libvirt-gconfig/libvirt-gconfig-timer.c | 81 +++ libvirt-gconfig/libvirt-gconfig-timer.h | 68 ++ libvirt-gconfig/libvirt-gconfig.h |2 + libvirt-gconfig/libvirt-gconfig.sym |8 +++ 7 files changed, 312 insertions(+), 0 deletions(-) create mode 100644 libvirt-gconfig/libvirt-gconfig-clock.c create mode 100644 libvirt-gconfig/libvirt-gconfig-clock.h create mode 100644 libvirt-gconfig/libvirt-gconfig-timer.c create mode 100644 libvirt-gconfig/libvirt-gconfig-timer.h diff --git a/libvirt-gconfig/Makefile.am b/libvirt-gconfig/Makefile.am index 52eff79..a2f01fd 100644 --- a/libvirt-gconfig/Makefile.am +++ b/libvirt-gconfig/Makefile.am @@ -8,6 +8,7 @@ GCONFIG_HEADER_FILES = \ libvirt-gconfig.h \ libvirt-gconfig-object.h \ libvirt-gconfig-capabilities.h \ + libvirt-gconfig-clock.h \ libvirt-gconfig-domain.h \ libvirt-gconfig-domain-snapshot.h \ libvirt-gconfig-helpers.h \ @@ -16,6 +17,7 @@ GCONFIG_HEADER_FILES = \ libvirt-gconfig-network-filter.h \ libvirt-gconfig-node-device.h \ libvirt-gconfig-secret.h \ + libvirt-gconfig-timer.h \ libvirt-gconfig-storage-pool.h \ libvirt-gconfig-storage-vol.h noinst_HEADERS = \ @@ -24,6 +26,7 @@ noinst_HEADERS = \ GCONFIG_SOURCE_FILES = \ libvirt-gconfig-object.c \ libvirt-gconfig-capabilities.c \ + libvirt-gconfig-clock.c \ libvirt-gconfig-domain.c \ libvirt-gconfig-domain-snapshot.c \ libvirt-gconfig-helpers.c \ @@ -32,6 +35,7 @@ GCONFIG_SOURCE_FILES = \ libvirt-gconfig-network-filter.c \ libvirt-gconfig-node-device.c \ libvirt-gconfig-secret.c \ + libvirt-gconfig-timer.c \ libvirt-gconfig-storage-pool.c \ libvirt-gconfig-storage-vol.c diff --git a/libvirt-gconfig/libvirt-gconfig-clock.c b/libvirt-gconfig/libvirt-gconfig-clock.c new file mode 100644 index 000..1f28efb --- /dev/null +++ b/libvirt-gconfig/libvirt-gconfig-clock.c @@ -0,0 +1,81 @@ +/* + * libvirt-gobject-config_clock.c: libvirt glib integration + * + * Copyright (C) 2011 Red Hat + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: Christophe Fergeau cferg...@redhat.com + */ + +#include config.h + +#include string.h + +#include libxml/tree.h + +#include libvirt-gconfig/libvirt-gconfig.h + +extern gboolean debugFlag; + +#define DEBUG(fmt, ...) do { if (G_UNLIKELY(debugFlag)) g_debug(fmt, ## __VA_ARGS__); } while (0) + +#define GVIR_CONFIG_CLOCK_GET_PRIVATE(obj) \ +(G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_TYPE_CONFIG_CLOCK, GVirConfigClockPrivate)) + +struct _GVirConfigClockPrivate +{ +gboolean unused; +}; + +G_DEFINE_TYPE(GVirConfigClock, gvir_config_clock, GVIR_TYPE_CONFIG_OBJECT); + + +static void gvir_config_clock_class_init(GVirConfigClockClass *klass) +{ +g_type_class_add_private(klass, sizeof(GVirConfigClockPrivate)); +} + + +static void gvir_config_clock_init(GVirConfigClock *klock) +{ +GVirConfigClockPrivate *priv; + +DEBUG(Init GVirConfigClock=%p, klock); + +priv = klock-priv = GVIR_CONFIG_CLOCK_GET_PRIVATE(klock); + +memset(priv, 0, sizeof(*priv)); +} + + +GVirConfigClock *gvir_config_clock_new(void) +{ +GVirConfigObject *object; + +object = gvir_config_object_new(GVIR_TYPE_CONFIG_CLOCK, +clock, NULL); +return GVIR_CONFIG_CLOCK(object); +} + +GVirConfigClock *gvir_config_clock_new_from_xml(const gchar *xml, +GError **error) +{ +GVirConfigObject *object; + +object =
[libvirt] [libvirt-gconfig PATCHv2 13/32] Add gobject boilerplate for GVirConfigOs
--- libvirt-gconfig/Makefile.am |2 + libvirt-gconfig/libvirt-gconfig-os.c | 79 ++ libvirt-gconfig/libvirt-gconfig-os.h | 67 libvirt-gconfig/libvirt-gconfig.h|3 +- libvirt-gconfig/libvirt-gconfig.sym |4 ++ 5 files changed, 154 insertions(+), 1 deletions(-) create mode 100644 libvirt-gconfig/libvirt-gconfig-os.c create mode 100644 libvirt-gconfig/libvirt-gconfig-os.h diff --git a/libvirt-gconfig/Makefile.am b/libvirt-gconfig/Makefile.am index 13655f9..648ded0 100644 --- a/libvirt-gconfig/Makefile.am +++ b/libvirt-gconfig/Makefile.am @@ -19,6 +19,7 @@ GCONFIG_HEADER_FILES = \ libvirt-gconfig-network.h \ libvirt-gconfig-network-filter.h \ libvirt-gconfig-node-device.h \ + libvirt-gconfig-os.h \ libvirt-gconfig-secret.h \ libvirt-gconfig-timer.h \ libvirt-gconfig-storage-pool.h \ @@ -38,6 +39,7 @@ GCONFIG_SOURCE_FILES = \ libvirt-gconfig-network.c \ libvirt-gconfig-network-filter.c \ libvirt-gconfig-node-device.c \ + libvirt-gconfig-os.c \ libvirt-gconfig-secret.c \ libvirt-gconfig-timer.c \ libvirt-gconfig-storage-pool.c \ diff --git a/libvirt-gconfig/libvirt-gconfig-os.c b/libvirt-gconfig/libvirt-gconfig-os.c new file mode 100644 index 000..c09e32a --- /dev/null +++ b/libvirt-gconfig/libvirt-gconfig-os.c @@ -0,0 +1,79 @@ +/* + * libvirt-gobject-config_os.c: libvirt glib integration + * + * Copyright (C) 2011 Red Hat + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: Christophe Fergeau cferg...@gmail.com + */ + +#include config.h + +#include string.h + +#include libxml/tree.h + +#include libvirt-gconfig/libvirt-gconfig.h + +extern gboolean debugFlag; + +#define DEBUG(fmt, ...) do { if (G_UNLIKELY(debugFlag)) g_debug(fmt, ## __VA_ARGS__); } while (0) + +#define GVIR_CONFIG_OS_GET_PRIVATE(obj) \ +(G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_TYPE_CONFIG_OS, GVirConfigOsPrivate)) + +struct _GVirConfigOsPrivate +{ +gboolean unused; +}; + +G_DEFINE_TYPE(GVirConfigOs, gvir_config_os, GVIR_TYPE_CONFIG_OBJECT); + + +static void gvir_config_os_class_init(GVirConfigOsClass *klass) +{ +g_type_class_add_private(klass, sizeof(GVirConfigOsPrivate)); +} + + +static void gvir_config_os_init(GVirConfigOs *os) +{ +GVirConfigOsPrivate *priv; + +DEBUG(Init GVirConfigOs=%p, os); + +priv = os-priv = GVIR_CONFIG_OS_GET_PRIVATE(os); + +memset(priv, 0, sizeof(*priv)); +} + + +GVirConfigOs *gvir_config_os_new(void) +{ +GVirConfigObject *object; + +object = gvir_config_object_new(GVIR_TYPE_CONFIG_OS, os, NULL); +return GVIR_CONFIG_OS(object); +} + +GVirConfigOs *gvir_config_os_new_from_xml(const gchar *xml, GError **error) +{ +GVirConfigObject *object; + +object = gvir_config_object_new_from_xml(GVIR_TYPE_CONFIG_OS, os, + NULL, xml, error); +return GVIR_CONFIG_OS(object); +} diff --git a/libvirt-gconfig/libvirt-gconfig-os.h b/libvirt-gconfig/libvirt-gconfig-os.h new file mode 100644 index 000..716f588 --- /dev/null +++ b/libvirt-gconfig/libvirt-gconfig-os.h @@ -0,0 +1,67 @@ +/* + * libvirt-gobject-os.c: libvirt gobject integration + * + * Copyright (C) 2011 Red Hat + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330,
[libvirt] [libvirt-gconfig PATCHv2 05/32] Use new helpers to simplify gvir_config_domain_set_features
--- libvirt-gconfig/libvirt-gconfig-domain.c | 17 +++-- libvirt-gconfig/libvirt-gconfig-domain.h |1 - 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/libvirt-gconfig/libvirt-gconfig-domain.c b/libvirt-gconfig/libvirt-gconfig-domain.c index d971a95..5db6bc4 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain.c +++ b/libvirt-gconfig/libvirt-gconfig-domain.c @@ -224,27 +224,16 @@ GStrv gvir_config_domain_get_features(GVirConfigDomain *domain) void gvir_config_domain_set_features(GVirConfigDomain *domain, const GStrv features) { -xmlNodePtr parent_node; xmlNodePtr features_node; -xmlNodePtr old_node; GStrv it; -parent_node = gvir_config_object_get_xml_node(GVIR_CONFIG_OBJECT(domain)); -features_node = xmlNewDocNode(parent_node-doc, NULL, - (xmlChar *)features, NULL); +features_node = gvir_config_object_replace_child(GVIR_CONFIG_OBJECT(domain), + features); for (it = features; *it != NULL; it++) { xmlNodePtr node; -node = xmlNewDocNode(parent_node-doc, NULL, (xmlChar *)*it, NULL); +node = xmlNewDocNode(features_node-doc, NULL, (xmlChar *)*it, NULL); xmlAddChild(features_node, node); } - -old_node = gvir_config_xml_get_element(parent_node, features, NULL); -if (old_node) { -old_node = xmlReplaceNode(old_node, features_node); -xmlFreeNode(old_node); -} else { -xmlAddChild(parent_node, features_node); -} g_object_notify(G_OBJECT(domain), features); } diff --git a/libvirt-gconfig/libvirt-gconfig-domain.h b/libvirt-gconfig/libvirt-gconfig-domain.h index d9f0c09..6cc8f31 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain.h +++ b/libvirt-gconfig/libvirt-gconfig-domain.h @@ -70,7 +70,6 @@ GStrv gvir_config_domain_get_features(GVirConfigDomain *domain); void gvir_config_domain_set_features(GVirConfigDomain *domain, const GStrv features); - G_END_DECLS #endif /* __LIBVIRT_GCONFIG_DOMAIN_H__ */ -- 1.7.7.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-gconfig PATCHv2 15/32] Implement gvir_config_domain_set_os
-- v2: use g_return_if_fail to test function args for sanity --- libvirt-gconfig/libvirt-gconfig-domain.c | 12 libvirt-gconfig/libvirt-gconfig-domain.h |2 ++ libvirt-gconfig/libvirt-gconfig.h|4 +++- libvirt-gconfig/libvirt-gconfig.sym |1 + 4 files changed, 18 insertions(+), 1 deletions(-) diff --git a/libvirt-gconfig/libvirt-gconfig-domain.c b/libvirt-gconfig/libvirt-gconfig-domain.c index 4c4ca53..bc2a1f3 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain.c +++ b/libvirt-gconfig/libvirt-gconfig-domain.c @@ -249,3 +249,15 @@ void gvir_config_domain_set_clock(GVirConfigDomain *domain, clock_node = gvir_config_object_get_xml_node(GVIR_CONFIG_OBJECT(klock)); gvir_config_object_set_child(GVIR_CONFIG_OBJECT(domain), clock_node); } + +void gvir_config_domain_set_os(GVirConfigDomain *domain, + GVirConfigOs *os) +{ +xmlNodePtr os_node; + +g_return_if_fail(GVIR_IS_CONFIG_DOMAIN(domain)); +g_return_if_fail(GVIR_IS_CONFIG_OS(os)); + +os_node = gvir_config_object_get_xml_node(GVIR_CONFIG_OBJECT(os)); +gvir_config_object_set_child(GVIR_CONFIG_OBJECT(domain), os_node); +} diff --git a/libvirt-gconfig/libvirt-gconfig-domain.h b/libvirt-gconfig/libvirt-gconfig-domain.h index 6f822cf..37effe4 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain.h +++ b/libvirt-gconfig/libvirt-gconfig-domain.h @@ -71,6 +71,8 @@ void gvir_config_domain_set_features(GVirConfigDomain *domain, const GStrv features); void gvir_config_domain_set_clock(GVirConfigDomain *domain, GVirConfigClock *klock); +void gvir_config_domain_set_os(GVirConfigDomain *domain, + GVirConfigOs *os); G_END_DECLS diff --git a/libvirt-gconfig/libvirt-gconfig.h b/libvirt-gconfig/libvirt-gconfig.h index 482c088..0f09d4f 100644 --- a/libvirt-gconfig/libvirt-gconfig.h +++ b/libvirt-gconfig/libvirt-gconfig.h @@ -29,7 +29,6 @@ #include libvirt-gconfig/libvirt-gconfig-object.h #include libvirt-gconfig/libvirt-gconfig-capabilities.h #include libvirt-gconfig/libvirt-gconfig-clock.h -#include libvirt-gconfig/libvirt-gconfig-domain.h #include libvirt-gconfig/libvirt-gconfig-domain-snapshot.h #include libvirt-gconfig/libvirt-gconfig-enum-types.h #include libvirt-gconfig/libvirt-gconfig-helpers.h @@ -43,4 +42,7 @@ #include libvirt-gconfig/libvirt-gconfig-storage-pool.h #include libvirt-gconfig/libvirt-gconfig-storage-vol.h +/* Must come last since it uses types defined in the other headers */ +#include libvirt-gconfig/libvirt-gconfig-domain.h + #endif /* __LIBVIRT_GCONFIG_H__ */ diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym index 1a924c1..0d68f92 100644 --- a/libvirt-gconfig/libvirt-gconfig.sym +++ b/libvirt-gconfig/libvirt-gconfig.sym @@ -16,6 +16,7 @@ LIBVIRT_GOBJECT_0.0.1 { gvir_config_domain_new; gvir_config_domain_new_from_xml; gvir_config_domain_set_clock; + gvir_config_domain_set_os; gvir_config_domain_get_features; gvir_config_domain_set_features; gvir_config_domain_get_memory; -- 1.7.7.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-gconfig PATCHv2 09/32] Use glib-mkenums to register enums with glib
We don't currently have any enum in our API, but we will need some. This commit adds the generation of libvirt-gconfig-enum-types.[ch] using glib-mkenums. These files will register the various enums that will get added to libvirt-gconfig header files with glib. -- v2: move libvirt-gconfig-enum-types.h to HEADERS in Makefile.am so that it's installed --- configure.ac |4 ++ libvirt-gconfig/Makefile.am| 23 +++- .../libvirt-gconfig-enum-types.c.template | 36 .../libvirt-gconfig-enum-types.h.template | 24 + libvirt-gconfig/libvirt-gconfig.h |1 + 5 files changed, 86 insertions(+), 2 deletions(-) create mode 100644 libvirt-gconfig/libvirt-gconfig-enum-types.c.template create mode 100644 libvirt-gconfig/libvirt-gconfig-enum-types.h.template diff --git a/configure.ac b/configure.ac index 464160c..3281baa 100644 --- a/configure.ac +++ b/configure.ac @@ -52,6 +52,10 @@ PKG_CHECK_MODULES(LIBXML2, libxml-2.0 = $LIBXML2_REQUIRED) GTK_DOC_CHECK([1.10],[--flavour no-tmpl]) +# Setup GLIB_MKENUMS to use glib-mkenums even if GLib is uninstalled. +GLIB_MKENUMS=`$PKG_CONFIG --variable=glib_mkenums glib-2.0` +AC_SUBST(GLIB_MKENUMS) + dnl Extra link-time flags for Cygwin. dnl Copied from libxml2 configure.in, but I removed mingw changes dnl for now since I'm not supporting mingw at present. - RWMJ diff --git a/libvirt-gconfig/Makefile.am b/libvirt-gconfig/Makefile.am index a2f01fd..13655f9 100644 --- a/libvirt-gconfig/Makefile.am +++ b/libvirt-gconfig/Makefile.am @@ -1,6 +1,9 @@ SUBDIRS = . tests -EXTRA_DIST = libvirt-gconfig.sym +EXTRA_DIST = \ + libvirt-gconfig.sym \ + libvirt-gconfig-enum-types.h.template \ + libvirt-gconfig-enum-types.c.template lib_LTLIBRARIES = libvirt-gconfig-1.0.la @@ -29,6 +32,7 @@ GCONFIG_SOURCE_FILES = \ libvirt-gconfig-clock.c \ libvirt-gconfig-domain.c \ libvirt-gconfig-domain-snapshot.c \ + libvirt-gconfig-enum-types.c \ libvirt-gconfig-helpers.c \ libvirt-gconfig-interface.c \ libvirt-gconfig-network.c \ @@ -41,7 +45,8 @@ GCONFIG_SOURCE_FILES = \ libvirt_gconfig_1_0_ladir = $(includedir)/libvirt-gconfig-1.0/libvirt-gconfig libvirt_gconfig_1_0_la_HEADERS = \ - $(GCONFIG_HEADER_FILES) + $(GCONFIG_HEADER_FILES) \ + libvirt-gconfig-enum-types.h libvirt_gconfig_1_0_la_SOURCES = \ $(libvirt_gconfig_1_0_la_HEADERS) \ $(GCONFIG_SOURCE_FILES) @@ -65,6 +70,20 @@ libvirt_gconfig_1_0_la_LDFLAGS = \ -Wl,--version-script=$(srcdir)/libvirt-gconfig.sym \ -version-info $(LIBVIRT_GLIB_VERSION_INFO) +BUILT_SOURCES = \ + libvirt-gconfig-enum-types.c \ + libvirt-gconfig-enum-types.h + +libvirt-gconfig-enum-types.h: $(GCONFIG_HEADER_FILES) libvirt-gconfig-enum-types.h.template + $(AM_V_GEN) ( cd $(srcdir) \ +$(GLIB_MKENUMS) --template libvirt-gconfig-enum-types.h.template $(GCONFIG_HEADER_FILES) ) libvirt-gconfig-enum-types.h.tmp \ +sed -e s/G_TYPE_VIR/GVIR_TYPE/ -e s/g_vir/gvir/ libvirt-gconfig-enum-types.h.tmp libvirt-gconfig-enum-types.h + +libvirt-gconfig-enum-types.c: $(GCONFIG_HEADER_FILES) libvirt-gconfig-enum-types.c.template + $(AM_V_GEN) ( cd $(srcdir) \ +$(GLIB_MKENUMS) --template libvirt-gconfig-enum-types.c.template $(GCONFIG_HEADER_FILES) ) libvirt-gconfig-enum-types.c.tmp \ +sed -e s/G_TYPE_VIR/GVIR_TYPE/ -e s/g_vir/gvir/ libvirt-gconfig-enum-types.c.tmp libvirt-gconfig-enum-types.c + if WITH_GOBJECT_INTROSPECTION LibvirtGConfig-1.0.gir: libvirt-gconfig-1.0.la $(G_IR_SCANNER) Makefile.am diff --git a/libvirt-gconfig/libvirt-gconfig-enum-types.c.template b/libvirt-gconfig/libvirt-gconfig-enum-types.c.template new file mode 100644 index 000..cccea77 --- /dev/null +++ b/libvirt-gconfig/libvirt-gconfig-enum-types.c.template @@ -0,0 +1,36 @@ +/*** BEGIN file-header ***/ +#include libvirt-gconfig/libvirt-gconfig.h + +/*** END file-header ***/ + +/*** BEGIN file-production ***/ +/* enumerations from @filename@ */ +/*** END file-production ***/ + +/*** BEGIN value-header ***/ +GType +@enum_name@_get_type (void) +{ + static volatile gsize g_define_type_id__volatile = 0; + + if (g_once_init_enter (g_define_type_id__volatile)) +{ + static const G@Type@Value values[] = { +/*** END value-header ***/ + +/*** BEGIN value-production ***/ +{ @VALUENAME@, @VALUENAME@, @valuenick@ }, +/*** END value-production ***/ + +/*** BEGIN value-tail ***/ +{ 0, NULL, NULL } + }; + GType g_define_type_id = +g_@type@_register_static
[libvirt] [libvirt-gconfig PATCHv2 19/32] Add gobject boilerplate for GVirConfigDeviceDisk
--- libvirt-gconfig/Makefile.am |2 + libvirt-gconfig/libvirt-gconfig-device-disk.c | 81 + libvirt-gconfig/libvirt-gconfig-device-disk.h | 68 + libvirt-gconfig/libvirt-gconfig.h |1 + libvirt-gconfig/libvirt-gconfig.sym |4 + 5 files changed, 156 insertions(+), 0 deletions(-) create mode 100644 libvirt-gconfig/libvirt-gconfig-device-disk.c create mode 100644 libvirt-gconfig/libvirt-gconfig-device-disk.h diff --git a/libvirt-gconfig/Makefile.am b/libvirt-gconfig/Makefile.am index dda41e8..4bc7a21 100644 --- a/libvirt-gconfig/Makefile.am +++ b/libvirt-gconfig/Makefile.am @@ -13,6 +13,7 @@ GCONFIG_HEADER_FILES = \ libvirt-gconfig-capabilities.h \ libvirt-gconfig-clock.h \ libvirt-gconfig-device.h \ + libvirt-gconfig-device-disk.h \ libvirt-gconfig-domain.h \ libvirt-gconfig-domain-snapshot.h \ libvirt-gconfig-helpers.h \ @@ -33,6 +34,7 @@ GCONFIG_SOURCE_FILES = \ libvirt-gconfig-capabilities.c \ libvirt-gconfig-clock.c \ libvirt-gconfig-device.c \ + libvirt-gconfig-device-disk.c \ libvirt-gconfig-domain.c \ libvirt-gconfig-domain-snapshot.c \ libvirt-gconfig-enum-types.c \ diff --git a/libvirt-gconfig/libvirt-gconfig-device-disk.c b/libvirt-gconfig/libvirt-gconfig-device-disk.c new file mode 100644 index 000..44c1f8e --- /dev/null +++ b/libvirt-gconfig/libvirt-gconfig-device-disk.c @@ -0,0 +1,81 @@ +/* + * libvirt-gobject-config-device-disk.c: libvirt glib integration + * + * Copyright (C) 2011 Red Hat + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: Christophe Fergeau cferg...@gmail.com + */ + +#include config.h + +#include string.h + +#include libxml/tree.h + +#include libvirt-gconfig/libvirt-gconfig.h + +extern gboolean debugFlag; + +#define DEBUG(fmt, ...) do { if (G_UNLIKELY(debugFlag)) g_debug(fmt, ## __VA_ARGS__); } while (0) + +#define GVIR_CONFIG_DEVICE_DISK_GET_PRIVATE(obj) \ +(G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_TYPE_CONFIG_DEVICE_DISK, GVirConfigDeviceDiskPrivate)) + +struct _GVirConfigDeviceDiskPrivate +{ +gboolean unused; +}; + +G_DEFINE_TYPE(GVirConfigDeviceDisk, gvir_config_device_disk, GVIR_TYPE_CONFIG_DEVICE); + + +static void gvir_config_device_disk_class_init(GVirConfigDeviceDiskClass *klass) +{ +g_type_class_add_private(klass, sizeof(GVirConfigDeviceDiskPrivate)); +} + + +static void gvir_config_device_disk_init(GVirConfigDeviceDisk *disk) +{ +GVirConfigDeviceDiskPrivate *priv; + +DEBUG(Init GVirConfigDeviceDisk=%p, disk); + +priv = disk-priv = GVIR_CONFIG_DEVICE_DISK_GET_PRIVATE(disk); + +memset(priv, 0, sizeof(*priv)); +} + + +GVirConfigDeviceDisk *gvir_config_device_disk_new(void) +{ +GVirConfigObject *object; + +object = gvir_config_object_new(GVIR_TYPE_CONFIG_DEVICE_DISK, +disk, NULL); +return GVIR_CONFIG_DEVICE_DISK(object); +} + +GVirConfigDeviceDisk *gvir_config_device_disk_new_from_xml(const gchar *xml, + GError **error) +{ +GVirConfigObject *object; + +object = gvir_config_object_new_from_xml(GVIR_TYPE_CONFIG_DEVICE_DISK, + disk, NULL, xml, error); +return GVIR_CONFIG_DEVICE_DISK(object); +} diff --git a/libvirt-gconfig/libvirt-gconfig-device-disk.h b/libvirt-gconfig/libvirt-gconfig-device-disk.h new file mode 100644 index 000..ef771d5 --- /dev/null +++ b/libvirt-gconfig/libvirt-gconfig-device-disk.h @@ -0,0 +1,68 @@ +/* + * libvirt-gobject-device-disk.c: libvirt gobject integration + * + * Copyright (C) 2011 Red Hat + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is
[libvirt] [libvirt-gconfig PATCHv2 14/32] Add some GVirConfigOs setters
-- v2: merged several related commits use safer g_strcmp0 for string comparison use g_return_if_fail to test function args for sanity --- libvirt-gconfig/libvirt-gconfig-os.c | 138 ++ libvirt-gconfig/libvirt-gconfig-os.h | 27 +++ libvirt-gconfig/libvirt-gconfig.sym | 11 +++ 3 files changed, 176 insertions(+), 0 deletions(-) diff --git a/libvirt-gconfig/libvirt-gconfig-os.c b/libvirt-gconfig/libvirt-gconfig-os.c index c09e32a..b430eb6 100644 --- a/libvirt-gconfig/libvirt-gconfig-os.c +++ b/libvirt-gconfig/libvirt-gconfig-os.c @@ -27,6 +27,8 @@ #include libxml/tree.h #include libvirt-gconfig/libvirt-gconfig.h +#include libvirt-gconfig/libvirt-gconfig-helpers-private.h +#include libvirt-gconfig/libvirt-gconfig-object-private.h extern gboolean debugFlag; @@ -77,3 +79,139 @@ GVirConfigOs *gvir_config_os_new_from_xml(const gchar *xml, GError **error) NULL, xml, error); return GVIR_CONFIG_OS(object); } + +void gvir_config_os_set_os_type(GVirConfigOs *os, GVirConfigOsType type) +{ +xmlNodePtr node; +const char *type_str; + +g_return_if_fail(GVIR_IS_CONFIG_OS(os)); + +node = gvir_config_object_replace_child(GVIR_CONFIG_OBJECT(os), type); +g_return_if_fail(node != NULL); +type_str = gvir_config_genum_get_nick(GVIR_TYPE_CONFIG_OS_TYPE, type); +g_return_if_fail(type_str != NULL); +xmlNodeSetContent(node, (xmlChar*)type_str); +} + +void gvir_config_os_set_loader(GVirConfigOs *os, const char * loader) +{ +gvir_config_object_set_node_content(GVIR_CONFIG_OBJECT(os), +loader, loader); +} + +void gvir_config_os_enable_boot_menu(GVirConfigOs *os, gboolean enable) +{ +xmlNodePtr node; + +g_return_if_fail(GVIR_IS_CONFIG_OS(os)); + +node = gvir_config_object_replace_child(GVIR_CONFIG_OBJECT(os), bootmenu); +g_return_if_fail(node != NULL); +if (enable) +xmlNewProp(node, (xmlChar*)enable, (xmlChar*)yes); +else +xmlNewProp(node, (xmlChar*)enable, (xmlChar*)no); +} + +void gvir_config_os_bios_enable_serial(GVirConfigOs *os, gboolean enable) +{ +xmlNodePtr node; + +g_return_if_fail(GVIR_IS_CONFIG_OS(os)); + +node = gvir_config_object_replace_child(GVIR_CONFIG_OBJECT(os), bios); +g_return_if_fail(node != NULL); +if (enable) +xmlNewProp(node, (xmlChar*)useserial, (xmlChar*)yes); +else +xmlNewProp(node, (xmlChar*)useserial, (xmlChar*)no); +} + +void gvir_config_os_set_smbios_mode(GVirConfigOs *os, +GVirConfigOsSmBiosMode mode) +{ +xmlNodePtr node; +const char *mode_str; + +g_return_if_fail(GVIR_IS_CONFIG_OS(os)); + +node = gvir_config_object_replace_child(GVIR_CONFIG_OBJECT(os), smbios); +g_return_if_fail(node != NULL); +mode_str = gvir_config_genum_get_nick(GVIR_TYPE_CONFIG_OS_SM_BIOS_MODE, + mode); +if (mode_str != NULL) +xmlNewProp(node, (xmlChar*)mode, (xmlChar*)mode_str); +} + +/** + * gvir_config_os_set_boot_devices: + * @boot_devices: (in) (element-type LibvirtGConfig.OsBootDevice): + */ +void gvir_config_os_set_boot_devices(GVirConfigOs *os, GList *boot_devices) +{ +GList *it; +xmlNodePtr os_node; +xmlNodePtr node; + +g_return_if_fail(GVIR_IS_CONFIG_OS(os)); + +os_node = gvir_config_object_get_xml_node(GVIR_CONFIG_OBJECT(os)); +g_return_if_fail(os_node != NULL); + +node = os_node-children; +while (node != NULL) { +xmlNodePtr next_node; +next_node = node-next; +if (g_strcmp0(boot, (char *)node-name) == 0) { +xmlUnlinkNode(node); +xmlFreeNode(node); +} +node = next_node; +} + +for (it = boot_devices; it != NULL; it = it-next) { +const char *dev; + +dev = gvir_config_genum_get_nick(GVIR_TYPE_CONFIG_OS_BOOT_DEVICE, + GPOINTER_TO_INT(it-data)); +g_warn_if_fail(dev != NULL); +if (dev != NULL) { +node = xmlNewDocNode(NULL, NULL, (xmlChar*)boot, NULL); +xmlNewProp(node, (xmlChar*)dev, (xmlChar*)dev); +xmlAddChild(os_node, node); +} +} +} + +void gvir_config_os_set_arch(GVirConfigOs *os, const char *arch) +{ +xmlNodePtr os_node; +xmlNodePtr os_type_node; + +g_return_if_fail(GVIR_IS_CONFIG_OS(os)); + +os_node = gvir_config_object_get_xml_node(GVIR_CONFIG_OBJECT(os)); +g_return_if_fail(os_node != NULL); + +os_type_node = gvir_config_xml_get_element(os_node, type, NULL); +g_return_if_fail(os_type_node != NULL); + +xmlNewProp(os_type_node, (xmlChar*)arch, (xmlChar*)arch); +} + +void gvir_config_os_set_machine(GVirConfigOs *os, const char *machine) +{ +xmlNodePtr os_node; +xmlNodePtr os_type_node; + +g_return_if_fail(GVIR_IS_CONFIG_OS(os)); + +os_node =
[libvirt] [libvirt-gconfig PATCHv2 17/32] Add GVirConfigDomain::vcpu
--- libvirt-gconfig/libvirt-gconfig-domain.c | 29 libvirt-gconfig/libvirt-gconfig-domain.h |3 ++ libvirt-gconfig/libvirt-gconfig.sym|2 + libvirt-gconfig/tests/test-domain-create.c |1 + 4 files changed, 35 insertions(+), 0 deletions(-) diff --git a/libvirt-gconfig/libvirt-gconfig-domain.c b/libvirt-gconfig/libvirt-gconfig-domain.c index bc2a1f3..64fdf50 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain.c +++ b/libvirt-gconfig/libvirt-gconfig-domain.c @@ -47,6 +47,7 @@ enum { PROP_0, PROP_NAME, PROP_MEMORY, +PROP_VCPU, PROP_FEATURES }; @@ -64,6 +65,9 @@ static void gvir_config_domain_get_property(GObject *object, case PROP_MEMORY: g_value_set_uint64(value, gvir_config_domain_get_memory(domain)); break; +case PROP_VCPU: +g_value_set_uint64(value, gvir_config_domain_get_vcpus(domain)); +break; case PROP_FEATURES: g_value_take_boxed(value, gvir_config_domain_get_features(domain)); break; @@ -87,6 +91,9 @@ static void gvir_config_domain_set_property(GObject *object, case PROP_MEMORY: gvir_config_domain_set_memory(domain, g_value_get_uint64(value)); break; +case PROP_VCPU: +gvir_config_domain_set_vcpus(domain, g_value_get_uint64(value)); +break; case PROP_FEATURES: gvir_config_domain_set_features(domain, g_value_get_boxed(value)); break; @@ -123,6 +130,15 @@ static void gvir_config_domain_class_init(GVirConfigDomainClass *klass) G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); g_object_class_install_property(object_class, +PROP_VCPU, +g_param_spec_uint64(vcpu, +Virtual CPUs, +Maximum Number of Guest Virtual CPUs, +0, G_MAXUINT64, +1, +G_PARAM_READWRITE | + G_PARAM_STATIC_STRINGS)); +g_object_class_install_property(object_class, PROP_FEATURES, g_param_spec_boxed(features, Features, @@ -193,6 +209,19 @@ void gvir_config_domain_set_memory(GVirConfigDomain *domain, guint64 memory) g_object_notify(G_OBJECT(domain), memory); } +guint64 gvir_config_domain_get_vcpus(GVirConfigDomain *domain) +{ +return gvir_config_object_get_node_content_uint64(GVIR_CONFIG_OBJECT(domain), + vcpu); +} + +void gvir_config_domain_set_vcpus(GVirConfigDomain *domain, guint64 vcpu_count) +{ +gvir_config_object_set_node_content_uint64(GVIR_CONFIG_OBJECT(domain), + vcpu, vcpu_count); +g_object_notify(G_OBJECT(domain), vcpu); +} + /** * gvir_config_domain_get_features: * Returns: (transfer full): diff --git a/libvirt-gconfig/libvirt-gconfig-domain.h b/libvirt-gconfig/libvirt-gconfig-domain.h index 37effe4..3ca6228 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain.h +++ b/libvirt-gconfig/libvirt-gconfig-domain.h @@ -66,6 +66,9 @@ char *gvir_config_domain_get_name(GVirConfigDomain *domain); void gvir_config_domain_set_name(GVirConfigDomain *domain, const char *name); guint64 gvir_config_domain_get_memory(GVirConfigDomain *domain); void gvir_config_domain_set_memory(GVirConfigDomain *domain, guint64 memory); +guint64 gvir_config_domain_get_vcpus(GVirConfigDomain *domain); +void gvir_config_domain_set_vcpus(GVirConfigDomain *domain, + guint64 vcpu_count); GStrv gvir_config_domain_get_features(GVirConfigDomain *domain); void gvir_config_domain_set_features(GVirConfigDomain *domain, const GStrv features); diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym index 0d68f92..23bb7f5 100644 --- a/libvirt-gconfig/libvirt-gconfig.sym +++ b/libvirt-gconfig/libvirt-gconfig.sym @@ -23,6 +23,8 @@ LIBVIRT_GOBJECT_0.0.1 { gvir_config_domain_set_memory; gvir_config_domain_get_name; gvir_config_domain_set_name; + gvir_config_domain_get_vcpus; + gvir_config_domain_set_vcpus; gvir_config_domain_snapshot_get_type; gvir_config_domain_snapshot_new; diff --git a/libvirt-gconfig/tests/test-domain-create.c b/libvirt-gconfig/tests/test-domain-create.c index 8abca00..af960a9 100644 --- a/libvirt-gconfig/tests/test-domain-create.c +++ b/libvirt-gconfig/tests/test-domain-create.c @@ -49,6 +49,7 @@ int main(void)
[libvirt] [libvirt-gconfig PATCHv2 22/32] Add gvir_config_object_add_child
It's similar to gvir_config_object_replace_child except that if the current node already has a child with the correct name, it returns the existing child instead of replacing it. -- v2: instead of adding an argument to gvir_config_object_new_child, split the function in 2 separate ones, gvir_config_object_add_child and gvir_config_object_replace_child. use g_return_if_fail to test function args for sanity --- libvirt-gconfig/libvirt-gconfig-object-private.h |2 ++ libvirt-gconfig/libvirt-gconfig-object.c | 20 2 files changed, 22 insertions(+), 0 deletions(-) diff --git a/libvirt-gconfig/libvirt-gconfig-object-private.h b/libvirt-gconfig/libvirt-gconfig-object-private.h index a14a792..0cedaef 100644 --- a/libvirt-gconfig/libvirt-gconfig-object-private.h +++ b/libvirt-gconfig/libvirt-gconfig-object-private.h @@ -35,6 +35,8 @@ void gvir_config_object_set_node_content(GVirConfigObject *object, void gvir_config_object_set_node_content_uint64(GVirConfigObject *object, const char *node_name, guint64 value); +xmlNodePtr gvir_config_object_add_child(GVirConfigObject *object, +const char *child_name); xmlNodePtr gvir_config_object_replace_child(GVirConfigObject *object, const char *child_name); void gvir_config_object_set_child(GVirConfigObject *object, diff --git a/libvirt-gconfig/libvirt-gconfig-object.c b/libvirt-gconfig/libvirt-gconfig-object.c index ac10e88..142d714 100644 --- a/libvirt-gconfig/libvirt-gconfig-object.c +++ b/libvirt-gconfig/libvirt-gconfig-object.c @@ -333,6 +333,26 @@ gvir_config_object_set_child(GVirConfigObject *object, xmlNodePtr child) } G_GNUC_INTERNAL xmlNodePtr +gvir_config_object_add_child(GVirConfigObject *object, + const char *child_name) +{ +xmlNodePtr new_node; +xmlNodePtr old_node; + +g_return_val_if_fail(GVIR_IS_CONFIG_OBJECT(object), NULL); + +new_node = xmlNewDocNode(NULL, NULL, (xmlChar *)child_name, NULL); +old_node = gvir_config_object_set_child_internal(object, new_node, + FALSE); +if (old_node != NULL) { +xmlFreeNode(new_node); +return old_node; +} + +return new_node; +} + +G_GNUC_INTERNAL xmlNodePtr gvir_config_object_replace_child(GVirConfigObject *object, const char *child_name) { -- 1.7.7.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-gconfig PATCHv2 21/32] Add gvir_config_domain_set_devices
-- v2: use g_return_if_fail to test function args for sanity --- libvirt-gconfig/libvirt-gconfig-domain.c | 23 +++ libvirt-gconfig/libvirt-gconfig-domain.h |2 ++ libvirt-gconfig/libvirt-gconfig.sym |3 ++- 3 files changed, 27 insertions(+), 1 deletions(-) diff --git a/libvirt-gconfig/libvirt-gconfig-domain.c b/libvirt-gconfig/libvirt-gconfig-domain.c index 64fdf50..b6d705b 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain.c +++ b/libvirt-gconfig/libvirt-gconfig-domain.c @@ -290,3 +290,26 @@ void gvir_config_domain_set_os(GVirConfigDomain *domain, os_node = gvir_config_object_get_xml_node(GVIR_CONFIG_OBJECT(os)); gvir_config_object_set_child(GVIR_CONFIG_OBJECT(domain), os_node); } + +/** + * gvir_config_domain_set_devices: + * @devices: (in) (element-type LibvirtGConfig.Device): + */ +void gvir_config_domain_set_devices(GVirConfigDomain *domain, +GList *devices) +{ +xmlNodePtr devices_node; +GList *it; + +g_return_if_fail(GVIR_IS_CONFIG_DOMAIN(domain)); + +devices_node = gvir_config_object_replace_child(GVIR_CONFIG_OBJECT(domain), +devices); +for (it = devices; it != NULL; it = it-next) { +GVirConfigDevice *device = GVIR_CONFIG_DEVICE(it-data); +xmlNodePtr node; + +node = gvir_config_object_get_xml_node(GVIR_CONFIG_OBJECT(device)); +xmlAddChild(devices_node, node); +} +} diff --git a/libvirt-gconfig/libvirt-gconfig-domain.h b/libvirt-gconfig/libvirt-gconfig-domain.h index 3ca6228..da798e8 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain.h +++ b/libvirt-gconfig/libvirt-gconfig-domain.h @@ -76,6 +76,8 @@ void gvir_config_domain_set_clock(GVirConfigDomain *domain, GVirConfigClock *klock); void gvir_config_domain_set_os(GVirConfigDomain *domain, GVirConfigOs *os); +void gvir_config_domain_set_devices(GVirConfigDomain *domain, +GList *devices); G_END_DECLS diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym index f059f9d..35dc3c7 100644 --- a/libvirt-gconfig/libvirt-gconfig.sym +++ b/libvirt-gconfig/libvirt-gconfig.sym @@ -28,13 +28,14 @@ LIBVIRT_GOBJECT_0.0.1 { gvir_config_domain_new; gvir_config_domain_new_from_xml; gvir_config_domain_set_clock; - gvir_config_domain_set_os; + gvir_config_domain_set_devices; gvir_config_domain_get_features; gvir_config_domain_set_features; gvir_config_domain_get_memory; gvir_config_domain_set_memory; gvir_config_domain_get_name; gvir_config_domain_set_name; + gvir_config_domain_set_os; gvir_config_domain_get_vcpus; gvir_config_domain_set_vcpus; -- 1.7.7.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-gconfig PATCHv2 16/32] Add test for GVirConfigOs
--- libvirt-gconfig/tests/test-domain-create.c | 19 ++- 1 files changed, 18 insertions(+), 1 deletions(-) diff --git a/libvirt-gconfig/tests/test-domain-create.c b/libvirt-gconfig/tests/test-domain-create.c index a5c5b99..8abca00 100644 --- a/libvirt-gconfig/tests/test-domain-create.c +++ b/libvirt-gconfig/tests/test-domain-create.c @@ -33,7 +33,6 @@ const char *features[] = { foo, bar, baz, NULL }; int main(void) { GVirConfigDomain *domain; -GVirConfigClock *klock; char *name; GStrv feat; unsigned int i; @@ -60,10 +59,28 @@ int main(void) } g_strfreev(feat); +/* clock node */ +GVirConfigClock *klock; + klock = gvir_config_clock_new(); gvir_config_clock_set_offset(klock, GVIR_CONFIG_CLOCK_UTC); gvir_config_domain_set_clock(domain, klock); +/* os node */ +GVirConfigOs *os; +GList *devices = NULL; + +os = gvir_config_os_new(); +gvir_config_os_set_os_type(os, GVIR_CONFIG_OS_TYPE_HVM); +gvir_config_os_set_arch(os, x86_64); +devices = g_list_append(devices, + GINT_TO_POINTER(GVIR_CONFIG_OS_BOOT_DEVICE_CDROM)); +devices = g_list_append(devices, + GINT_TO_POINTER(GVIR_CONFIG_OS_BOOT_DEVICE_NETWORK)); +gvir_config_os_set_boot_devices(os, devices); +g_list_free(devices); +gvir_config_domain_set_os(domain, os); + xml = gvir_config_object_to_xml(GVIR_CONFIG_OBJECT(domain)); g_print(%s\n, xml); g_free(xml); -- 1.7.7.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-gconfig PATCHv2 18/32] Add gobject boilerplate for GVirConfigDevice
This is an abstract type which will be used as a base class for all objects stored in the devices section of a domain. --- libvirt-gconfig/Makefile.am |2 + libvirt-gconfig/libvirt-gconfig-device.c | 61 libvirt-gconfig/libvirt-gconfig-device.h | 64 ++ libvirt-gconfig/libvirt-gconfig.h|1 + libvirt-gconfig/libvirt-gconfig.sym |2 + 5 files changed, 130 insertions(+), 0 deletions(-) create mode 100644 libvirt-gconfig/libvirt-gconfig-device.c create mode 100644 libvirt-gconfig/libvirt-gconfig-device.h diff --git a/libvirt-gconfig/Makefile.am b/libvirt-gconfig/Makefile.am index 648ded0..dda41e8 100644 --- a/libvirt-gconfig/Makefile.am +++ b/libvirt-gconfig/Makefile.am @@ -12,6 +12,7 @@ GCONFIG_HEADER_FILES = \ libvirt-gconfig-object.h \ libvirt-gconfig-capabilities.h \ libvirt-gconfig-clock.h \ + libvirt-gconfig-device.h \ libvirt-gconfig-domain.h \ libvirt-gconfig-domain-snapshot.h \ libvirt-gconfig-helpers.h \ @@ -31,6 +32,7 @@ GCONFIG_SOURCE_FILES = \ libvirt-gconfig-object.c \ libvirt-gconfig-capabilities.c \ libvirt-gconfig-clock.c \ + libvirt-gconfig-device.c \ libvirt-gconfig-domain.c \ libvirt-gconfig-domain-snapshot.c \ libvirt-gconfig-enum-types.c \ diff --git a/libvirt-gconfig/libvirt-gconfig-device.c b/libvirt-gconfig/libvirt-gconfig-device.c new file mode 100644 index 000..ad08222 --- /dev/null +++ b/libvirt-gconfig/libvirt-gconfig-device.c @@ -0,0 +1,61 @@ +/* + * libvirt-gobject-config-device.c: libvirt glib integration + * + * Copyright (C) 2011 Red Hat + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: Christophe Fergeau cferg...@gmail.com + */ + +#include config.h + +#include string.h + +#include libxml/tree.h + +#include libvirt-gconfig/libvirt-gconfig.h + +extern gboolean debugFlag; + +#define DEBUG(fmt, ...) do { if (G_UNLIKELY(debugFlag)) g_debug(fmt, ## __VA_ARGS__); } while (0) + +#define GVIR_CONFIG_DEVICE_GET_PRIVATE(obj) \ +(G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_TYPE_CONFIG_DEVICE, GVirConfigDevicePrivate)) + +struct _GVirConfigDevicePrivate +{ +gboolean unused; +}; + +G_DEFINE_ABSTRACT_TYPE(GVirConfigDevice, gvir_config_device, GVIR_TYPE_CONFIG_OBJECT); + + +static void gvir_config_device_class_init(GVirConfigDeviceClass *klass) +{ +g_type_class_add_private(klass, sizeof(GVirConfigDevicePrivate)); +} + + +static void gvir_config_device_init(GVirConfigDevice *device) +{ +GVirConfigDevicePrivate *priv; + +DEBUG(Init GVirConfigDevice=%p, device); + +priv = device-priv = GVIR_CONFIG_DEVICE_GET_PRIVATE(device); + +memset(priv, 0, sizeof(*priv)); +} diff --git a/libvirt-gconfig/libvirt-gconfig-device.h b/libvirt-gconfig/libvirt-gconfig-device.h new file mode 100644 index 000..abd10c2 --- /dev/null +++ b/libvirt-gconfig/libvirt-gconfig-device.h @@ -0,0 +1,64 @@ +/* + * libvirt-gobject-device.c: libvirt gobject integration + * + * Copyright (C) 2011 Red Hat + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: Christophe Fergeau cferg...@gmail.com + */ + +#if !defined(__LIBVIRT_GCONFIG_H__) !defined(LIBVIRT_GCONFIG_BUILD) +#error Only libvirt-gconfig/libvirt-gconfig.h can be included
[libvirt] [libvirt-gconfig PATCHv2 32/32] Add GVirConfigDeviceVideo
-- v2: use g_return_if_fail to test function args for sanity --- libvirt-gconfig/Makefile.am|2 + libvirt-gconfig/libvirt-gconfig-device-video.c | 133 libvirt-gconfig/libvirt-gconfig-device-video.h | 82 +++ libvirt-gconfig/libvirt-gconfig.h |1 + libvirt-gconfig/libvirt-gconfig.sym|8 ++ libvirt-gconfig/tests/test-domain-create.c |9 ++ 6 files changed, 235 insertions(+), 0 deletions(-) create mode 100644 libvirt-gconfig/libvirt-gconfig-device-video.c create mode 100644 libvirt-gconfig/libvirt-gconfig-device-video.h diff --git a/libvirt-gconfig/Makefile.am b/libvirt-gconfig/Makefile.am index 1be6233..05cdbd0 100644 --- a/libvirt-gconfig/Makefile.am +++ b/libvirt-gconfig/Makefile.am @@ -17,6 +17,7 @@ GCONFIG_HEADER_FILES = \ libvirt-gconfig-device-graphics.h \ libvirt-gconfig-device-graphics-spice.h \ libvirt-gconfig-device-input.h \ + libvirt-gconfig-device-video.h \ libvirt-gconfig-domain.h \ libvirt-gconfig-domain-snapshot.h \ libvirt-gconfig-helpers.h \ @@ -42,6 +43,7 @@ GCONFIG_SOURCE_FILES = \ libvirt-gconfig-device-graphics.c \ libvirt-gconfig-device-graphics-spice.c \ libvirt-gconfig-device-input.c \ + libvirt-gconfig-device-video.c \ libvirt-gconfig-domain.c \ libvirt-gconfig-domain-snapshot.c \ libvirt-gconfig-enum-types.c \ diff --git a/libvirt-gconfig/libvirt-gconfig-device-video.c b/libvirt-gconfig/libvirt-gconfig-device-video.c new file mode 100644 index 000..cbaf2f4 --- /dev/null +++ b/libvirt-gconfig/libvirt-gconfig-device-video.c @@ -0,0 +1,133 @@ +/* + * libvirt-gobject-config-device-video.c: libvirt glib integration + * + * Copyright (C) 2011 Red Hat + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: Christophe Fergeau cferg...@gmail.com + */ + +#include config.h + +#include string.h + +#include libxml/tree.h + +#include libvirt-gconfig/libvirt-gconfig.h +#include libvirt-gconfig/libvirt-gconfig-helpers-private.h +#include libvirt-gconfig/libvirt-gconfig-object-private.h + +extern gboolean debugFlag; + +#define DEBUG(fmt, ...) do { if (G_UNLIKELY(debugFlag)) g_debug(fmt, ## __VA_ARGS__); } while (0) + +#define GVIR_CONFIG_DEVICE_VIDEO_GET_PRIVATE(obj) \ +(G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_TYPE_CONFIG_DEVICE_VIDEO, GVirConfigDeviceVideoPrivate)) + +struct _GVirConfigDeviceVideoPrivate +{ +gboolean unused; +}; + +G_DEFINE_TYPE(GVirConfigDeviceVideo, gvir_config_device_video, GVIR_TYPE_CONFIG_DEVICE); + + +static void gvir_config_device_video_class_init(GVirConfigDeviceVideoClass *klass) +{ +g_type_class_add_private(klass, sizeof(GVirConfigDeviceVideoPrivate)); +} + + +static void gvir_config_device_video_init(GVirConfigDeviceVideo *device_video) +{ +GVirConfigDeviceVideoPrivate *priv; + +DEBUG(Init GVirConfigDeviceVideo=%p, device_video); + +priv = device_video-priv = GVIR_CONFIG_DEVICE_VIDEO_GET_PRIVATE(device_video); + +memset(priv, 0, sizeof(*priv)); +} + + +GVirConfigDeviceVideo *gvir_config_device_video_new(void) +{ +GVirConfigObject *object; + +object = gvir_config_object_new(GVIR_TYPE_CONFIG_DEVICE_VIDEO, +video, NULL); +return GVIR_CONFIG_DEVICE_VIDEO(object); +} + +GVirConfigDeviceVideo *gvir_config_device_video_new_from_xml(const gchar *xml, + GError **error) +{ +GVirConfigObject *object; + +object = gvir_config_object_new_from_xml(GVIR_TYPE_CONFIG_DEVICE_VIDEO, + video, NULL, xml, error); +return GVIR_CONFIG_DEVICE_VIDEO(object); +} + +void gvir_config_device_video_set_model(GVirConfigDeviceVideo *video, +GVirConfigDeviceVideoModel model) +{ +xmlNodePtr node; +const char *model_str; + +g_return_if_fail(GVIR_IS_CONFIG_DEVICE_VIDEO(video)); +node =
[libvirt] [libvirt-gconfig PATCHv2 25/32] GVirConfigInterface derives from GVirConfigDevice
This base class is mainly useful as a generic type when we manipulate list of devices regardless of their actual type. --- libvirt-gconfig/libvirt-gconfig-interface.c |2 +- libvirt-gconfig/libvirt-gconfig-interface.h |4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libvirt-gconfig/libvirt-gconfig-interface.c b/libvirt-gconfig/libvirt-gconfig-interface.c index b58a4b4..aadbc96 100644 --- a/libvirt-gconfig/libvirt-gconfig-interface.c +++ b/libvirt-gconfig/libvirt-gconfig-interface.c @@ -39,7 +39,7 @@ struct _GVirConfigInterfacePrivate gboolean unused; }; -G_DEFINE_TYPE(GVirConfigInterface, gvir_config_interface, GVIR_TYPE_CONFIG_OBJECT); +G_DEFINE_TYPE(GVirConfigInterface, gvir_config_interface, GVIR_TYPE_CONFIG_DEVICE); static void gvir_config_interface_class_init(GVirConfigInterfaceClass *klass) diff --git a/libvirt-gconfig/libvirt-gconfig-interface.h b/libvirt-gconfig/libvirt-gconfig-interface.h index 0728c29..2877341 100644 --- a/libvirt-gconfig/libvirt-gconfig-interface.h +++ b/libvirt-gconfig/libvirt-gconfig-interface.h @@ -42,7 +42,7 @@ typedef struct _GVirConfigInterfaceClass GVirConfigInterfaceClass; struct _GVirConfigInterface { -GVirConfigObject parent; +GVirConfigDevice parent; GVirConfigInterfacePrivate *priv; @@ -51,7 +51,7 @@ struct _GVirConfigInterface struct _GVirConfigInterfaceClass { -GVirConfigObjectClass parent_class; +GVirConfigDeviceClass parent_class; gpointer padding[20]; }; -- 1.7.7.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-gconfig PATCHv2 04/32] Add gvir_config_object_replace_child helper
This allows us to factor the code to add an XML node to a config object. -- v2: use g_return_if_fail to test function args for sanity replace object --- libvirt-gconfig/libvirt-gconfig-object-private.h |5 + libvirt-gconfig/libvirt-gconfig-object.c | 105 +++--- libvirt-gconfig/libvirt-gconfig.h|2 +- 3 files changed, 80 insertions(+), 32 deletions(-) diff --git a/libvirt-gconfig/libvirt-gconfig-object-private.h b/libvirt-gconfig/libvirt-gconfig-object-private.h index aec88bf..a14a792 100644 --- a/libvirt-gconfig/libvirt-gconfig-object-private.h +++ b/libvirt-gconfig/libvirt-gconfig-object-private.h @@ -35,6 +35,11 @@ void gvir_config_object_set_node_content(GVirConfigObject *object, void gvir_config_object_set_node_content_uint64(GVirConfigObject *object, const char *node_name, guint64 value); +xmlNodePtr gvir_config_object_replace_child(GVirConfigObject *object, +const char *child_name); +void gvir_config_object_set_child(GVirConfigObject *object, + xmlNodePtr child); + G_END_DECLS diff --git a/libvirt-gconfig/libvirt-gconfig-object.c b/libvirt-gconfig/libvirt-gconfig-object.c index 276be8c..ac10e88 100644 --- a/libvirt-gconfig/libvirt-gconfig-object.c +++ b/libvirt-gconfig/libvirt-gconfig-object.c @@ -297,34 +297,89 @@ gvir_config_object_get_node_content(GVirConfigObject *object, return gvir_config_xml_get_child_element_content_glib(node, node_name); } -/* FIXME: if there are multiple nodes with the same name, this function - * won't behave as expected. Should we get rid of the duplicated node names - * here? - */ -G_GNUC_INTERNAL void -gvir_config_object_set_node_content(GVirConfigObject *object, -const char *node_name, -const char *value) +static xmlNodePtr +gvir_config_object_set_child_internal(GVirConfigObject *object, + xmlNodePtr child, + gboolean overwrite) { xmlNodePtr parent_node; xmlNodePtr old_node; -xmlNodePtr new_node; -xmlChar *encoded_name; parent_node = gvir_config_object_get_xml_node(GVIR_CONFIG_OBJECT(object)); -encoded_name = xmlEncodeEntitiesReentrant(parent_node-doc, - (xmlChar *)value); -new_node = xmlNewDocNode(parent_node-doc, NULL, - (xmlChar *)node_name, encoded_name); -xmlFree(encoded_name); +g_return_val_if_fail (parent_node != NULL, NULL); -old_node = gvir_config_xml_get_element(parent_node, node_name, NULL); +old_node = gvir_config_xml_get_element(parent_node, child-name, NULL); +/* FIXME: should we make sure there are no multiple occurrences + * of this node? + */ if (old_node) { -old_node = xmlReplaceNode(old_node, new_node); -xmlFreeNode(old_node); +if (overwrite) { +old_node = xmlReplaceNode(old_node, child); +xmlFreeNode(old_node); +} else { +return old_node; +} } else { -xmlAddChild(parent_node, new_node); +xmlAddChild(parent_node, child); } + +return NULL; +} + +G_GNUC_INTERNAL void +gvir_config_object_set_child(GVirConfigObject *object, xmlNodePtr child) +{ +gvir_config_object_set_child_internal(object, child, TRUE); +} + +G_GNUC_INTERNAL xmlNodePtr +gvir_config_object_replace_child(GVirConfigObject *object, + const char *child_name) +{ +xmlNodePtr new_node; + +g_return_val_if_fail(GVIR_IS_CONFIG_OBJECT(object), NULL); +g_return_val_if_fail(child_name != NULL, NULL); + +new_node = xmlNewDocNode(NULL, NULL, (xmlChar *)child_name, NULL); +gvir_config_object_set_child_internal(object, new_node, TRUE); + +return new_node; +} + +G_GNUC_INTERNAL void +gvir_config_object_set_node_content(GVirConfigObject *object, +const char *node_name, +const char *value) +{ +xmlNodePtr node; +xmlChar *encoded_data; + +g_return_if_fail(GVIR_IS_CONFIG_OBJECT(object)); +g_return_if_fail(node_name != NULL); +g_return_if_fail(value != NULL); + +node = gvir_config_object_replace_child(object, node_name); +g_return_if_fail(node != NULL); +encoded_data = xmlEncodeEntitiesReentrant(node-doc, + (xmlChar *)value); +xmlNodeSetContent(node, encoded_data); +xmlFree(encoded_data); +} + +G_GNUC_INTERNAL void +gvir_config_object_set_node_content_uint64(GVirConfigObject *object, + const char *node_name, + guint64 value) +{ +char *str; + +
[libvirt] [libvirt-gconfig PATCHv2 12/32] Create clock object in domain creation test
--- libvirt-gconfig/tests/test-domain-create.c |5 + 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/libvirt-gconfig/tests/test-domain-create.c b/libvirt-gconfig/tests/test-domain-create.c index a719ed2..a5c5b99 100644 --- a/libvirt-gconfig/tests/test-domain-create.c +++ b/libvirt-gconfig/tests/test-domain-create.c @@ -33,6 +33,7 @@ const char *features[] = { foo, bar, baz, NULL }; int main(void) { GVirConfigDomain *domain; +GVirConfigClock *klock; char *name; GStrv feat; unsigned int i; @@ -59,6 +60,10 @@ int main(void) } g_strfreev(feat); +klock = gvir_config_clock_new(); +gvir_config_clock_set_offset(klock, GVIR_CONFIG_CLOCK_UTC); +gvir_config_domain_set_clock(domain, klock); + xml = gvir_config_object_to_xml(GVIR_CONFIG_OBJECT(domain)); g_print(%s\n, xml); g_free(xml); -- 1.7.7.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-gconfig PATCHv2 30/32] Add GObject boilerplate for GVirConfigDeviceGraphics
This is an abstract type which will be used as a base class for the various type of graphics devices (spice, vnc, ...) --- libvirt-gconfig/Makefile.am |2 + libvirt-gconfig/libvirt-gconfig-device-graphics.c | 61 libvirt-gconfig/libvirt-gconfig-device-graphics.h | 64 + libvirt-gconfig/libvirt-gconfig.h |1 + libvirt-gconfig/libvirt-gconfig.sym |2 + 5 files changed, 130 insertions(+), 0 deletions(-) create mode 100644 libvirt-gconfig/libvirt-gconfig-device-graphics.c create mode 100644 libvirt-gconfig/libvirt-gconfig-device-graphics.h diff --git a/libvirt-gconfig/Makefile.am b/libvirt-gconfig/Makefile.am index 76861a1..8aaa827 100644 --- a/libvirt-gconfig/Makefile.am +++ b/libvirt-gconfig/Makefile.am @@ -14,6 +14,7 @@ GCONFIG_HEADER_FILES = \ libvirt-gconfig-clock.h \ libvirt-gconfig-device.h \ libvirt-gconfig-device-disk.h \ + libvirt-gconfig-device-graphics.h \ libvirt-gconfig-device-input.h \ libvirt-gconfig-domain.h \ libvirt-gconfig-domain-snapshot.h \ @@ -37,6 +38,7 @@ GCONFIG_SOURCE_FILES = \ libvirt-gconfig-clock.c \ libvirt-gconfig-device.c \ libvirt-gconfig-device-disk.c \ + libvirt-gconfig-device-graphics.c \ libvirt-gconfig-device-input.c \ libvirt-gconfig-domain.c \ libvirt-gconfig-domain-snapshot.c \ diff --git a/libvirt-gconfig/libvirt-gconfig-device-graphics.c b/libvirt-gconfig/libvirt-gconfig-device-graphics.c new file mode 100644 index 000..b659d08 --- /dev/null +++ b/libvirt-gconfig/libvirt-gconfig-device-graphics.c @@ -0,0 +1,61 @@ +/* + * libvirt-gobject-config-device-graphics.c: libvirt glib integration + * + * Copyright (C) 2011 Red Hat + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: Christophe Fergeau cferg...@gmail.com + */ + +#include config.h + +#include string.h + +#include libxml/tree.h + +#include libvirt-gconfig/libvirt-gconfig.h + +extern gboolean debugFlag; + +#define DEBUG(fmt, ...) do { if (G_UNLIKELY(debugFlag)) g_debug(fmt, ## __VA_ARGS__); } while (0) + +#define GVIR_CONFIG_DEVICE_GRAPHICS_GET_PRIVATE(obj) \ +(G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_TYPE_CONFIG_DEVICE_GRAPHICS, GVirConfigDeviceGraphicsPrivate)) + +struct _GVirConfigDeviceGraphicsPrivate +{ +gboolean unused; +}; + +G_DEFINE_ABSTRACT_TYPE(GVirConfigDeviceGraphics, gvir_config_device_graphics, GVIR_TYPE_CONFIG_DEVICE); + + +static void gvir_config_device_graphics_class_init(GVirConfigDeviceGraphicsClass *klass) +{ +g_type_class_add_private(klass, sizeof(GVirConfigDeviceGraphicsPrivate)); +} + + +static void gvir_config_device_graphics_init(GVirConfigDeviceGraphics *device_graphics) +{ +GVirConfigDeviceGraphicsPrivate *priv; + +DEBUG(Init GVirConfigDeviceGraphics=%p, device_graphics); + +priv = device_graphics-priv = GVIR_CONFIG_DEVICE_GRAPHICS_GET_PRIVATE(device_graphics); + +memset(priv, 0, sizeof(*priv)); +} diff --git a/libvirt-gconfig/libvirt-gconfig-device-graphics.h b/libvirt-gconfig/libvirt-gconfig-device-graphics.h new file mode 100644 index 000..12f1d5b --- /dev/null +++ b/libvirt-gconfig/libvirt-gconfig-device-graphics.h @@ -0,0 +1,64 @@ +/* + * libvirt-gobject-device-graphics.c: libvirt gobject integration + * + * Copyright (C) 2011 Red Hat + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not,
[libvirt] [libvirt-gconfig PATCHv2 20/32] Add various GVirConfigDeviceDisk setters
-- v2: use g_return_if_fail to test function args for sanity --- libvirt-gconfig/libvirt-gconfig-device-disk.c | 50 + libvirt-gconfig/libvirt-gconfig-device-disk.h | 25 libvirt-gconfig/libvirt-gconfig.sym |6 +++ 3 files changed, 81 insertions(+), 0 deletions(-) diff --git a/libvirt-gconfig/libvirt-gconfig-device-disk.c b/libvirt-gconfig/libvirt-gconfig-device-disk.c index 44c1f8e..e34e9a0 100644 --- a/libvirt-gconfig/libvirt-gconfig-device-disk.c +++ b/libvirt-gconfig/libvirt-gconfig-device-disk.c @@ -27,6 +27,8 @@ #include libxml/tree.h #include libvirt-gconfig/libvirt-gconfig.h +#include libvirt-gconfig/libvirt-gconfig-helpers-private.h +#include libvirt-gconfig/libvirt-gconfig-object-private.h extern gboolean debugFlag; @@ -79,3 +81,51 @@ GVirConfigDeviceDisk *gvir_config_device_disk_new_from_xml(const gchar *xml, disk, NULL, xml, error); return GVIR_CONFIG_DEVICE_DISK(object); } + +void gvir_config_device_disk_set_type(GVirConfigDeviceDisk *disk, + GVirConfigDeviceDiskType type) +{ +xmlNodePtr node; +const char *type_str; + +g_return_if_fail(GVIR_IS_CONFIG_DEVICE_DISK(disk)); + +node = gvir_config_object_get_xml_node(GVIR_CONFIG_OBJECT(disk)); +g_return_if_fail(node != NULL); +type_str = gvir_config_genum_get_nick(GVIR_TYPE_CONFIG_DEVICE_DISK_TYPE, + type); +g_return_if_fail(type_str != NULL); +xmlNewProp(node, (xmlChar*)type, (xmlChar*)type_str); +} + +void gvir_config_device_disk_set_guest_device_type(GVirConfigDeviceDisk *disk, + GVirConfigDeviceDiskGuestDeviceType type) +{ +xmlNodePtr node; +const char *type_str; + +g_return_if_fail(GVIR_IS_CONFIG_DEVICE_DISK(disk)); + +node = gvir_config_object_get_xml_node(GVIR_CONFIG_OBJECT(disk)); +g_return_if_fail(node != NULL); +type_str = gvir_config_genum_get_nick(GVIR_TYPE_CONFIG_DEVICE_DISK_GUEST_DEVICE_TYPE, + type); +g_return_if_fail(type_str != NULL); +xmlNewProp(node, (xmlChar*)device, (xmlChar*)type_str); +} + +void gvir_config_device_disk_set_snapshot_type(GVirConfigDeviceDisk *disk, + GVirConfigDeviceDiskSnapshotType type) +{ +xmlNodePtr node; +const char *type_str; + +g_return_if_fail(GVIR_IS_CONFIG_DEVICE_DISK(disk)); + +node = gvir_config_object_get_xml_node(GVIR_CONFIG_OBJECT(disk)); +g_return_if_fail(node != NULL); +type_str = gvir_config_genum_get_nick(GVIR_TYPE_CONFIG_DEVICE_DISK_SNAPSHOT_TYPE, + type); +g_return_if_fail(type_str != NULL); +xmlNewProp(node, (xmlChar*)snapshot, (xmlChar*)type_str); +} diff --git a/libvirt-gconfig/libvirt-gconfig-device-disk.h b/libvirt-gconfig/libvirt-gconfig-device-disk.h index ef771d5..e597815 100644 --- a/libvirt-gconfig/libvirt-gconfig-device-disk.h +++ b/libvirt-gconfig/libvirt-gconfig-device-disk.h @@ -56,6 +56,24 @@ struct _GVirConfigDeviceDiskClass gpointer padding[20]; }; +typedef enum { +GVIR_CONFIG_DEVICE_DISK_FILE, +GVIR_CONFIG_DEVICE_DISK_BLOCK, +GVIR_CONFIG_DEVICE_DISK_DIR, +GVIR_CONFIG_DEVICE_DISK_NETWORK +} GVirConfigDeviceDiskType; + +typedef enum { +GVIR_CONFIG_DEVICE_DISK_GUEST_DEVICE_DISK, +GVIR_CONFIG_DEVICE_DISK_GUEST_DEVICE_FLOPPY, +GVIR_CONFIG_DEVICE_DISK_GUEST_DEVICE_CDROM +} GVirConfigDeviceDiskGuestDeviceType; + +typedef enum { +GVIR_CONFIG_DEVICE_DISK_SNAPSHOT_NO, +GVIR_CONFIG_DEVICE_DISK_SNAPSHOT_INTERNAL, +GVIR_CONFIG_DEVICE_DISK_SNAPSHOT_EXTERNAL +} GVirConfigDeviceDiskSnapshotType; GType gvir_config_device_disk_get_type(void); @@ -63,6 +81,13 @@ GVirConfigDeviceDisk *gvir_config_device_disk_new(void); GVirConfigDeviceDisk *gvir_config_device_disk_new_from_xml(const gchar *xml, GError **error); +void gvir_config_device_disk_set_type(GVirConfigDeviceDisk *disk, + GVirConfigDeviceDiskType type); +void gvir_config_device_disk_set_guest_device_type(GVirConfigDeviceDisk *disk, + GVirConfigDeviceDiskGuestDeviceType type); +void gvir_config_device_disk_set_snapshot_type(GVirConfigDeviceDisk *disk, + GVirConfigDeviceDiskSnapshotType type); + G_END_DECLS #endif /* __LIBVIRT_GCONFIG_DEVICE_DISK_H__ */ diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym index b0e752a..f059f9d 100644 --- a/libvirt-gconfig/libvirt-gconfig.sym +++ b/libvirt-gconfig/libvirt-gconfig.sym @@ -15,8 +15,14 @@ LIBVIRT_GOBJECT_0.0.1 { gvir_config_device_get_type; gvir_config_device_disk_get_type; +
[libvirt] [libvirt-gconfig PATCHv2 29/32] Add GVirConfigDeviceInput
-- v2: use enum for input bus type use g_return_if_fail to test function args for sanity --- libvirt-gconfig/Makefile.am|2 + libvirt-gconfig/libvirt-gconfig-device-input.c | 113 libvirt-gconfig/libvirt-gconfig-device-input.h | 82 + libvirt-gconfig/libvirt-gconfig.h |1 + libvirt-gconfig/libvirt-gconfig.sym|7 ++ libvirt-gconfig/tests/test-domain-create.c | 15 +++- 6 files changed, 217 insertions(+), 3 deletions(-) create mode 100644 libvirt-gconfig/libvirt-gconfig-device-input.c create mode 100644 libvirt-gconfig/libvirt-gconfig-device-input.h diff --git a/libvirt-gconfig/Makefile.am b/libvirt-gconfig/Makefile.am index 4318124..76861a1 100644 --- a/libvirt-gconfig/Makefile.am +++ b/libvirt-gconfig/Makefile.am @@ -14,6 +14,7 @@ GCONFIG_HEADER_FILES = \ libvirt-gconfig-clock.h \ libvirt-gconfig-device.h \ libvirt-gconfig-device-disk.h \ + libvirt-gconfig-device-input.h \ libvirt-gconfig-domain.h \ libvirt-gconfig-domain-snapshot.h \ libvirt-gconfig-helpers.h \ @@ -36,6 +37,7 @@ GCONFIG_SOURCE_FILES = \ libvirt-gconfig-clock.c \ libvirt-gconfig-device.c \ libvirt-gconfig-device-disk.c \ + libvirt-gconfig-device-input.c \ libvirt-gconfig-domain.c \ libvirt-gconfig-domain-snapshot.c \ libvirt-gconfig-enum-types.c \ diff --git a/libvirt-gconfig/libvirt-gconfig-device-input.c b/libvirt-gconfig/libvirt-gconfig-device-input.c new file mode 100644 index 000..ed654e0 --- /dev/null +++ b/libvirt-gconfig/libvirt-gconfig-device-input.c @@ -0,0 +1,113 @@ +/* + * libvirt-gobject-config-device_input.c: libvirt glib integration + * + * Copyright (C) 2011 Red Hat + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: Christophe Fergeau cferg...@gmail.com + */ + +#include config.h + +#include string.h + +#include libxml/tree.h + +#include libvirt-gconfig/libvirt-gconfig.h +#include libvirt-gconfig/libvirt-gconfig-helpers-private.h +#include libvirt-gconfig/libvirt-gconfig-object-private.h + +extern gboolean debugFlag; + +#define DEBUG(fmt, ...) do { if (G_UNLIKELY(debugFlag)) g_debug(fmt, ## __VA_ARGS__); } while (0) + +#define GVIR_CONFIG_DEVICE_INPUT_GET_PRIVATE(obj) \ +(G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_TYPE_CONFIG_DEVICE_INPUT, GVirConfigDeviceInputPrivate)) + +struct _GVirConfigDeviceInputPrivate +{ +gboolean unused; +}; + +G_DEFINE_TYPE(GVirConfigDeviceInput, gvir_config_device_input, GVIR_TYPE_CONFIG_DEVICE); + + +static void gvir_config_device_input_class_init(GVirConfigDeviceInputClass *klass) +{ +g_type_class_add_private(klass, sizeof(GVirConfigDeviceInputPrivate)); +} + + +static void gvir_config_device_input_init(GVirConfigDeviceInput *device_input) +{ +GVirConfigDeviceInputPrivate *priv; + +DEBUG(Init GVirConfigDeviceInput=%p, device_input); + +priv = device_input-priv = GVIR_CONFIG_DEVICE_INPUT_GET_PRIVATE(device_input); + +memset(priv, 0, sizeof(*priv)); +} + + +GVirConfigDeviceInput *gvir_config_device_input_new(void) +{ +GVirConfigObject *object; + +object = gvir_config_object_new(GVIR_TYPE_CONFIG_DEVICE_INPUT, +input, NULL); +return GVIR_CONFIG_DEVICE_INPUT(object); +} + +GVirConfigDeviceInput *gvir_config_device_input_new_from_xml(const gchar *xml, + GError **error) +{ +GVirConfigObject *object; + +object = gvir_config_object_new_from_xml(GVIR_TYPE_CONFIG_DEVICE_INPUT, + input, NULL, xml, error); +return GVIR_CONFIG_DEVICE_INPUT(object); +} + +void gvir_config_device_input_set_device_type(GVirConfigDeviceInput *input, + GVirConfigDeviceInputDeviceType type) +{ +xmlNodePtr node; +const char *type_str; + +g_return_if_fail(GVIR_IS_CONFIG_DEVICE_INPUT(input)); +node =
[libvirt] [libvirt-gconfig PATCHv2 27/32] Add gvir_config_interface_network_set_source
--- .../libvirt-gconfig-interface-network.c| 13 + .../libvirt-gconfig-interface-network.h|3 +++ libvirt-gconfig/libvirt-gconfig.sym|1 + 3 files changed, 17 insertions(+), 0 deletions(-) diff --git a/libvirt-gconfig/libvirt-gconfig-interface-network.c b/libvirt-gconfig/libvirt-gconfig-interface-network.c index 6e88cda..aaeb44e 100644 --- a/libvirt-gconfig/libvirt-gconfig-interface-network.c +++ b/libvirt-gconfig/libvirt-gconfig-interface-network.c @@ -92,3 +92,16 @@ GVirConfigInterfaceNetwork *gvir_config_interface_network_new_from_xml(const gch schema, DATADIR /libvirt/schemas/interface.rng, NULL)); } + +void gvir_config_interface_network_set_source(GVirConfigInterfaceNetwork *interface, + const char *source) +{ +xmlNodePtr source_node; + +g_return_if_fail(GVIR_IS_CONFIG_INTERFACE_NETWORK(interface)); + +source_node = gvir_config_object_replace_child(GVIR_CONFIG_OBJECT(interface), + source); +g_return_if_fail(source_node != NULL); +xmlNewProp(source_node, (xmlChar*)network, (xmlChar*)source); +} diff --git a/libvirt-gconfig/libvirt-gconfig-interface-network.h b/libvirt-gconfig/libvirt-gconfig-interface-network.h index 0c0e542..ce29746 100644 --- a/libvirt-gconfig/libvirt-gconfig-interface-network.h +++ b/libvirt-gconfig/libvirt-gconfig-interface-network.h @@ -62,6 +62,9 @@ GType gvir_config_interface_network_get_type(void); GVirConfigInterfaceNetwork *gvir_config_interface_network_new(void); GVirConfigInterfaceNetwork *gvir_config_interface_network_new_from_xml(const gchar *xml, GError **error); + +void gvir_config_interface_network_set_source(GVirConfigInterfaceNetwork *interface, + const char *source); G_END_DECLS #endif /* __LIBVIRT_GCONFIG_INTERFACE_NETWORK_H__ */ diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym index 25eab10..6d7ee0e 100644 --- a/libvirt-gconfig/libvirt-gconfig.sym +++ b/libvirt-gconfig/libvirt-gconfig.sym @@ -53,6 +53,7 @@ LIBVIRT_GOBJECT_0.0.1 { gvir_config_interface_network_get_type; gvir_config_interface_network_new; gvir_config_interface_network_new_from_xml; + gvir_config_interface_network_set_source; gvir_config_network_get_type; gvir_config_network_new; -- 1.7.7.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-gconfig PATCHv2 23/32] More GVirConfigDeviceDisk setters
-- v2: fix gvir_config_device_disk_set_source use g_return_if_fail to test function args for sanity --- libvirt-gconfig/libvirt-gconfig-device-disk.c | 78 - libvirt-gconfig/libvirt-gconfig-device-disk.h | 10 +++ libvirt-gconfig/libvirt-gconfig.sym |7 ++- 3 files changed, 93 insertions(+), 2 deletions(-) diff --git a/libvirt-gconfig/libvirt-gconfig-device-disk.c b/libvirt-gconfig/libvirt-gconfig-device-disk.c index e34e9a0..acfd1ab 100644 --- a/libvirt-gconfig/libvirt-gconfig-device-disk.c +++ b/libvirt-gconfig/libvirt-gconfig-device-disk.c @@ -39,7 +39,7 @@ extern gboolean debugFlag; struct _GVirConfigDeviceDiskPrivate { -gboolean unused; +GVirConfigDeviceDiskType type; }; G_DEFINE_TYPE(GVirConfigDeviceDisk, gvir_config_device_disk, GVIR_TYPE_CONFIG_DEVICE); @@ -96,6 +96,7 @@ void gvir_config_device_disk_set_type(GVirConfigDeviceDisk *disk, type); g_return_if_fail(type_str != NULL); xmlNewProp(node, (xmlChar*)type, (xmlChar*)type_str); +disk-priv-type = type; } void gvir_config_device_disk_set_guest_device_type(GVirConfigDeviceDisk *disk, @@ -129,3 +130,78 @@ void gvir_config_device_disk_set_snapshot_type(GVirConfigDeviceDisk *disk, g_return_if_fail(type_str != NULL); xmlNewProp(node, (xmlChar*)snapshot, (xmlChar*)type_str); } + +void gvir_config_device_disk_set_source(GVirConfigDeviceDisk *disk, +const char *source) +{ +xmlNodePtr source_node; +const char *attribute_name; + +g_return_if_fail(GVIR_IS_CONFIG_DEVICE_DISK(disk)); +source_node = gvir_config_object_replace_child(GVIR_CONFIG_OBJECT(disk), + source); +g_return_if_fail(source_node != NULL); + +switch (disk-priv-type) { +case GVIR_CONFIG_DEVICE_DISK_FILE: +attribute_name = file; +break; +case GVIR_CONFIG_DEVICE_DISK_BLOCK: +attribute_name = dev; +break; +case GVIR_CONFIG_DEVICE_DISK_DIR: +attribute_name = dir; +break; +case GVIR_CONFIG_DEVICE_DISK_NETWORK: +attribute_name = protocol; +break; +default: +g_return_if_reached(); +} +xmlNewProp(source_node, (xmlChar*)attribute_name, (xmlChar*)source); +} + +void gvir_config_device_disk_set_driver_name(GVirConfigDeviceDisk *disk, + const char *driver_name) +{ +xmlNodePtr node; + +g_return_if_fail(GVIR_IS_CONFIG_DEVICE_DISK(disk)); +node = gvir_config_object_add_child(GVIR_CONFIG_OBJECT(disk), driver); +g_return_if_fail(node != NULL); +xmlNewProp(node, (xmlChar*)name, (xmlChar*)driver_name); + +} + +void gvir_config_device_disk_set_driver_type(GVirConfigDeviceDisk *disk, + const char *driver_type) +{ +xmlNodePtr node; + +g_return_if_fail(GVIR_IS_CONFIG_DEVICE_DISK(disk)); +node = gvir_config_object_add_child(GVIR_CONFIG_OBJECT(disk), driver); +g_return_if_fail(node != NULL); +xmlNewProp(node, (xmlChar*)type, (xmlChar*)driver_type); +} + +void gvir_config_device_disk_set_target_bus(GVirConfigDeviceDisk *disk, +const char *bus) +{ +xmlNodePtr node; + +g_return_if_fail(GVIR_IS_CONFIG_DEVICE_DISK(disk)); +node = gvir_config_object_add_child(GVIR_CONFIG_OBJECT(disk), target); +g_return_if_fail(node != NULL); +xmlNewProp(node, (xmlChar*)bus, (xmlChar*)bus); +} + +void gvir_config_device_disk_set_target_dev(GVirConfigDeviceDisk *disk, +const char *dev) +{ +xmlNodePtr node; + +g_return_if_fail(GVIR_IS_CONFIG_DEVICE_DISK(disk)); +node = gvir_config_object_add_child(GVIR_CONFIG_OBJECT(disk), target); +g_return_if_fail(node != NULL); +xmlNewProp(node, (xmlChar*)dev, (xmlChar*)dev); +} diff --git a/libvirt-gconfig/libvirt-gconfig-device-disk.h b/libvirt-gconfig/libvirt-gconfig-device-disk.h index e597815..ac89d9b 100644 --- a/libvirt-gconfig/libvirt-gconfig-device-disk.h +++ b/libvirt-gconfig/libvirt-gconfig-device-disk.h @@ -87,6 +87,16 @@ void gvir_config_device_disk_set_guest_device_type(GVirConfigDeviceDisk *disk, GVirConfigDeviceDiskGuestDeviceType type); void gvir_config_device_disk_set_snapshot_type(GVirConfigDeviceDisk *disk, GVirConfigDeviceDiskSnapshotType type); +void gvir_config_device_disk_set_source(GVirConfigDeviceDisk *disk, +const char *source); +void gvir_config_device_disk_set_driver_name(GVirConfigDeviceDisk *disk, + const char *driver_name); +void gvir_config_device_disk_set_driver_type(GVirConfigDeviceDisk *disk, +
[libvirt] [libvirt-gconfig PATCHv2 31/32] Add basic GVirConfigDeviceGraphicsSpice
Only the (non-TLS) port can be set on it -- v2: rename to GVirConfigDeviceGraphicsSpice fix node creation (missing type attribute) derive GVirConfigDeviceGraphicsSpice from GVirConfigDeviceGraphics use g_return_if_fail to test function args for sanity --- libvirt-gconfig/Makefile.am|2 + .../libvirt-gconfig-device-graphics-spice.c| 106 .../libvirt-gconfig-device-graphics-spice.h| 69 + libvirt-gconfig/libvirt-gconfig.h |1 + libvirt-gconfig/libvirt-gconfig.sym|5 + libvirt-gconfig/tests/test-domain-create.c |7 ++ 6 files changed, 190 insertions(+), 0 deletions(-) create mode 100644 libvirt-gconfig/libvirt-gconfig-device-graphics-spice.c create mode 100644 libvirt-gconfig/libvirt-gconfig-device-graphics-spice.h diff --git a/libvirt-gconfig/Makefile.am b/libvirt-gconfig/Makefile.am index 8aaa827..1be6233 100644 --- a/libvirt-gconfig/Makefile.am +++ b/libvirt-gconfig/Makefile.am @@ -15,6 +15,7 @@ GCONFIG_HEADER_FILES = \ libvirt-gconfig-device.h \ libvirt-gconfig-device-disk.h \ libvirt-gconfig-device-graphics.h \ + libvirt-gconfig-device-graphics-spice.h \ libvirt-gconfig-device-input.h \ libvirt-gconfig-domain.h \ libvirt-gconfig-domain-snapshot.h \ @@ -39,6 +40,7 @@ GCONFIG_SOURCE_FILES = \ libvirt-gconfig-device.c \ libvirt-gconfig-device-disk.c \ libvirt-gconfig-device-graphics.c \ + libvirt-gconfig-device-graphics-spice.c \ libvirt-gconfig-device-input.c \ libvirt-gconfig-domain.c \ libvirt-gconfig-domain-snapshot.c \ diff --git a/libvirt-gconfig/libvirt-gconfig-device-graphics-spice.c b/libvirt-gconfig/libvirt-gconfig-device-graphics-spice.c new file mode 100644 index 000..6694f57 --- /dev/null +++ b/libvirt-gconfig/libvirt-gconfig-device-graphics-spice.c @@ -0,0 +1,106 @@ +/* + * libvirt-gobject-config-device-graphics-spice.c: libvirt glib integration + * + * Copyright (C) 2011 Red Hat + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: Christophe Fergeau cferg...@gmail.com + */ + +#include config.h + +#include string.h + +#include libxml/tree.h + +#include libvirt-gconfig/libvirt-gconfig.h +#include libvirt-gconfig/libvirt-gconfig-helpers-private.h +#include libvirt-gconfig/libvirt-gconfig-object-private.h + +extern gboolean debugFlag; + +#define DEBUG(fmt, ...) do { if (G_UNLIKELY(debugFlag)) g_debug(fmt, ## __VA_ARGS__); } while (0) + +#define GVIR_CONFIG_DEVICE_GRAPHICS_SPICE_GET_PRIVATE(obj) \ +(G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_TYPE_CONFIG_DEVICE_GRAPHICS_SPICE, GVirConfigDeviceGraphicsSpicePrivate)) + +struct _GVirConfigDeviceGraphicsSpicePrivate +{ +gboolean unused; +}; + +G_DEFINE_TYPE(GVirConfigDeviceGraphicsSpice, gvir_config_device_graphics_spice, GVIR_TYPE_CONFIG_DEVICE_GRAPHICS); + + +static void gvir_config_device_graphics_spice_class_init(GVirConfigDeviceGraphicsSpiceClass *klass) +{ +g_type_class_add_private(klass, sizeof(GVirConfigDeviceGraphicsSpicePrivate)); +} + + +static void gvir_config_device_graphics_spice_init(GVirConfigDeviceGraphicsSpice *graphics_spice) +{ +GVirConfigDeviceGraphicsSpicePrivate *priv; + +DEBUG(Init GVirConfigDeviceGraphicsSpice=%p, graphics_spice); + +priv = graphics_spice-priv = GVIR_CONFIG_DEVICE_GRAPHICS_SPICE_GET_PRIVATE(graphics_spice); + +memset(priv, 0, sizeof(*priv)); +} + + +GVirConfigDeviceGraphicsSpice *gvir_config_device_graphics_spice_new(void) +{ +xmlDocPtr doc; +xmlNodePtr node; + +doc = xmlNewDoc((xmlChar *)1.0); +node= xmlNewDocNode(doc, NULL, (xmlChar *)graphics, NULL); +xmlNewProp(doc-children, (xmlChar*)type, (xmlChar*)spice); +xmlDocSetRootElement(doc, node); +return GVIR_CONFIG_DEVICE_GRAPHICS_SPICE(g_object_new(GVIR_TYPE_CONFIG_DEVICE_GRAPHICS_SPICE, + node, node, +
[libvirt] [libvirt-gconfig PATCHv2 24/32] Add test for adding a disk device
--- libvirt-gconfig/tests/test-domain-create.c | 19 +++ 1 files changed, 19 insertions(+), 0 deletions(-) diff --git a/libvirt-gconfig/tests/test-domain-create.c b/libvirt-gconfig/tests/test-domain-create.c index af960a9..db22eb5 100644 --- a/libvirt-gconfig/tests/test-domain-create.c +++ b/libvirt-gconfig/tests/test-domain-create.c @@ -80,8 +80,27 @@ int main(void) GINT_TO_POINTER(GVIR_CONFIG_OS_BOOT_DEVICE_NETWORK)); gvir_config_os_set_boot_devices(os, devices); g_list_free(devices); +devices = NULL; gvir_config_domain_set_os(domain, os); +/* device node */ +GVirConfigDeviceDisk *disk; + +disk = gvir_config_device_disk_new(); +gvir_config_device_disk_set_type(disk, GVIR_CONFIG_DEVICE_DISK_FILE); +gvir_config_device_disk_set_guest_device_type(disk, GVIR_CONFIG_DEVICE_DISK_GUEST_DEVICE_DISK); +gvir_config_device_disk_set_source(disk, /tmp/foo/bar); +gvir_config_device_disk_set_driver_name(disk, qemu); +gvir_config_device_disk_set_driver_type(disk, qcow2); +gvir_config_device_disk_set_target_bus(disk, ide); +gvir_config_device_disk_set_target_dev(disk, hda); + +devices = g_list_append(devices, disk); +gvir_config_domain_set_devices(domain, devices); +g_list_free(devices); +devices = NULL; + + xml = gvir_config_object_to_xml(GVIR_CONFIG_OBJECT(domain)); g_print(%s\n, xml); g_free(xml); -- 1.7.7.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-gconfig PATCHv2 26/32] Add GVirConfigInterfaceNetwork
Make GVirConfigInterface an abstract base class, and move the actual code in subclasses. This will make handling of the various types of network interfaces more understandable and more logical with respect to the corresponding XML. -- v2: use g_return_if_fail to test function args for sanity --- libvirt-gconfig/Makefile.am|2 + .../libvirt-gconfig-interface-network.c| 94 .../libvirt-gconfig-interface-network.h| 67 ++ libvirt-gconfig/libvirt-gconfig-interface.c| 28 +- libvirt-gconfig/libvirt-gconfig-interface.h|5 - libvirt-gconfig/libvirt-gconfig.h |1 + libvirt-gconfig/libvirt-gconfig.sym|6 +- 7 files changed, 171 insertions(+), 32 deletions(-) create mode 100644 libvirt-gconfig/libvirt-gconfig-interface-network.c create mode 100644 libvirt-gconfig/libvirt-gconfig-interface-network.h diff --git a/libvirt-gconfig/Makefile.am b/libvirt-gconfig/Makefile.am index 4bc7a21..4318124 100644 --- a/libvirt-gconfig/Makefile.am +++ b/libvirt-gconfig/Makefile.am @@ -18,6 +18,7 @@ GCONFIG_HEADER_FILES = \ libvirt-gconfig-domain-snapshot.h \ libvirt-gconfig-helpers.h \ libvirt-gconfig-interface.h \ + libvirt-gconfig-interface-network.h \ libvirt-gconfig-network.h \ libvirt-gconfig-network-filter.h \ libvirt-gconfig-node-device.h \ @@ -40,6 +41,7 @@ GCONFIG_SOURCE_FILES = \ libvirt-gconfig-enum-types.c \ libvirt-gconfig-helpers.c \ libvirt-gconfig-interface.c \ + libvirt-gconfig-interface-network.c \ libvirt-gconfig-network.c \ libvirt-gconfig-network-filter.c \ libvirt-gconfig-node-device.c \ diff --git a/libvirt-gconfig/libvirt-gconfig-interface-network.c b/libvirt-gconfig/libvirt-gconfig-interface-network.c new file mode 100644 index 000..6e88cda --- /dev/null +++ b/libvirt-gconfig/libvirt-gconfig-interface-network.c @@ -0,0 +1,94 @@ +/* + * libvirt-gobject-config-interface_network-network.c: libvirt glib integration + * + * Copyright (C) 2008 Daniel P. Berrange + * Copyright (C) 2011 Red Hat + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: Daniel P. Berrange berra...@redhat.com + * Author: Christophe Fergeau cferg...@redhat.com + */ + +#include config.h + +#include string.h + +#include libvirt-gconfig/libvirt-gconfig.h +#include libvirt-gconfig/libvirt-gconfig-helpers-private.h +#include libvirt-gconfig/libvirt-gconfig-object-private.h + +extern gboolean debugFlag; + +#define DEBUG(fmt, ...) do { if (G_UNLIKELY(debugFlag)) g_debug(fmt, ## __VA_ARGS__); } while (0) + +#define GVIR_CONFIG_INTERFACE_NETWORK_GET_PRIVATE(obj) \ +(G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_TYPE_CONFIG_INTERFACE_NETWORK, GVirConfigInterfaceNetworkPrivate)) + +struct _GVirConfigInterfaceNetworkPrivate +{ +gboolean unused; +}; + +G_DEFINE_TYPE(GVirConfigInterfaceNetwork, gvir_config_interface_network, GVIR_TYPE_CONFIG_INTERFACE); + + +static void gvir_config_interface_network_class_init(GVirConfigInterfaceNetworkClass *klass) +{ +g_type_class_add_private(klass, sizeof(GVirConfigInterfaceNetworkPrivate)); +} + + +static void gvir_config_interface_network_init(GVirConfigInterfaceNetwork *conn) +{ +GVirConfigInterfaceNetworkPrivate *priv; + +DEBUG(Init GVirConfigInterfaceNetwork=%p, conn); + +priv = conn-priv = GVIR_CONFIG_INTERFACE_NETWORK_GET_PRIVATE(conn); + +memset(priv, 0, sizeof(*priv)); +} + + +GVirConfigInterfaceNetwork *gvir_config_interface_network_new(void) +{ +xmlDocPtr doc; +xmlNodePtr node; + +doc = xmlNewDoc((xmlChar *)1.0); +node= xmlNewDocNode(doc, NULL, (xmlChar *)interface, NULL); +xmlNewProp(doc-children, (xmlChar*)type, (xmlChar*)network); +xmlDocSetRootElement(doc, node); +return GVIR_CONFIG_INTERFACE_NETWORK(g_object_new(GVIR_TYPE_CONFIG_INTERFACE_NETWORK, + node, node, +
[libvirt] [libvirt-gconfig PATCHv2 28/32] Add network to creation test
--- libvirt-gconfig/tests/test-domain-create.c | 10 +- 1 files changed, 9 insertions(+), 1 deletions(-) diff --git a/libvirt-gconfig/tests/test-domain-create.c b/libvirt-gconfig/tests/test-domain-create.c index db22eb5..fa949f7 100644 --- a/libvirt-gconfig/tests/test-domain-create.c +++ b/libvirt-gconfig/tests/test-domain-create.c @@ -83,7 +83,7 @@ int main(void) devices = NULL; gvir_config_domain_set_os(domain, os); -/* device node */ +/* disk node */ GVirConfigDeviceDisk *disk; disk = gvir_config_device_disk_new(); @@ -96,6 +96,14 @@ int main(void) gvir_config_device_disk_set_target_dev(disk, hda); devices = g_list_append(devices, disk); + +/* network interface node */ +GVirConfigInterfaceNetwork *interface; + +interface = gvir_config_interface_network_new(); +gvir_config_interface_network_set_source(interface, default); +devices = g_list_append(devices, interface); + gvir_config_domain_set_devices(domain, devices); g_list_free(devices); devices = NULL; -- 1.7.7.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-glib] Add API to redefine an existing domain
From: Zeeshan Ali (Khattak) zeesha...@gnome.org --- libvirt-gobject/libvirt-gobject-domain.c | 48 ++ libvirt-gobject/libvirt-gobject-domain.h |3 ++ libvirt-gobject/libvirt-gobject.sym |1 + 3 files changed, 52 insertions(+), 0 deletions(-) diff --git a/libvirt-gobject/libvirt-gobject-domain.c b/libvirt-gobject/libvirt-gobject-domain.c index 1fa27bd..01ae1f4 100644 --- a/libvirt-gobject/libvirt-gobject-domain.c +++ b/libvirt-gobject/libvirt-gobject-domain.c @@ -449,6 +449,54 @@ GVirConfigDomain *gvir_domain_get_config(GVirDomain *dom, return conf; } +/** + * gvir_domain_set_config: + * @domain: the domain + * @conf: the new configuration for the domain + * @error: (allow-none): Place-holder for error or NULL + * + * Resets configuration of an existing domain. + * + * Note: If domain is already running, the new configuration will not take + * affect until domain reboots. + * + * Returns: TRUE on success, FALSE if an error occurred. + */ +gboolean gvir_domain_set_config(GVirDomain *domain, +GVirConfigDomain *conf, +GError **error) +{ +const gchar *xml; +virConnectPtr conn; +GVirDomainPrivate *priv = domain-priv; + +g_return_val_if_fail(GVIR_IS_DOMAIN (domain), FALSE); +g_return_val_if_fail(GVIR_IS_CONFIG_DOMAIN (conf), FALSE); +g_return_val_if_fail(error == NULL || *error == NULL, FALSE); + +xml = gvir_config_object_to_xml(GVIR_CONFIG_OBJECT(conf)); + +g_return_val_if_fail(xml != NULL, FALSE); + +if ((conn = virDomainGetConnect(priv-handle)) == NULL) { +if (error != NULL) +*error = gvir_error_new_literal(GVIR_DOMAIN_ERROR, +0, +Failed to get domain connection); +return FALSE; +} + +if (virDomainDefineXML(conn, xml) == NULL) { +if (error != NULL) +*error = gvir_error_new_literal(GVIR_DOMAIN_ERROR, +0, +Failed to set +domain configuration); +return FALSE; + } + + return TRUE; +} /** * gvir_domain_get_info: diff --git a/libvirt-gobject/libvirt-gobject-domain.h b/libvirt-gobject/libvirt-gobject-domain.h index 94bd53e..0479de8 100644 --- a/libvirt-gobject/libvirt-gobject-domain.h +++ b/libvirt-gobject/libvirt-gobject-domain.h @@ -123,6 +123,9 @@ GVirDomainInfo *gvir_domain_get_info(GVirDomain *dom, GVirConfigDomain *gvir_domain_get_config(GVirDomain *dom, guint64 flags, GError **err); +gboolean gvir_domain_set_config(GVirDomain *domain, +GVirConfigDomain *conf, +GError **err); gchar *gvir_domain_screenshot(GVirDomain *dom, GVirStream *stream, diff --git a/libvirt-gobject/libvirt-gobject.sym b/libvirt-gobject/libvirt-gobject.sym index 164b6b8..46c53f9 100644 --- a/libvirt-gobject/libvirt-gobject.sym +++ b/libvirt-gobject/libvirt-gobject.sym @@ -53,6 +53,7 @@ LIBVIRT_GOBJECT_0.0.1 { gvir_domain_shutdown; gvir_domain_reboot; gvir_domain_get_config; + gvir_domain_set_config; gvir_domain_get_info; gvir_domain_screenshot; -- 1.7.7.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [libvirt-glib] Add API to redefine an existing domain
Hi On Mon, Nov 21, 2011 at 6:53 PM, Zeeshan Ali (Khattak) zeesha...@gnome.org wrote: + g_return_val_if_fail(error == NULL || *error == NULL, FALSE); This is wrong, it should be error != NULL *error == NULL. + if (virDomainDefineXML(conn, xml) == NULL) { + if (error != NULL) + *error = gvir_error_new_literal(GVIR_DOMAIN_ERROR, + 0, + Failed to set + domain configuration); + return FALSE; + } Can you please verify that the return value is safe to ignore? I would really prefer we add a runtime check that verifiy the handle is the same as the one currently associated with the domain. -- Marc-André Lureau -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [libvirt-glib] Add API to redefine an existing domain
On Mon, Nov 21, 2011 at 9:27 PM, Marc-André Lureau marcandre.lur...@gmail.com wrote: Hi On Mon, Nov 21, 2011 at 6:53 PM, Zeeshan Ali (Khattak) zeesha...@gnome.org wrote: + g_return_val_if_fail(error == NULL || *error == NULL, FALSE); This is wrong, it should be error != NULL *error == NULL. + if (virDomainDefineXML(conn, xml) == NULL) { + if (error != NULL) + *error = gvir_error_new_literal(GVIR_DOMAIN_ERROR, + 0, + Failed to set + domain configuration); + return FALSE; + } Can you please verify that the return value is safe to ignore? Sorry, i don't get it. Verify how? I would really prefer we add a runtime check that verifiy the handle is the same as the one currently associated with the domain. Yeah, i'll add that! Forgot that it still applies. -- Regards, Zeeshan Ali (Khattak) FSF member#5124 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [libvirt-glib] Add API to redefine an existing domain
On Mon, Nov 21, 2011 at 8:45 PM, Zeeshan Ali (Khattak) zeesha...@gnome.org wrote: Sorry, i don't get it. Verify how? By doing what I proposed bellow, reading libvirt code, ask on libvirt list/maintainers, test etc.. I would really prefer we add a runtime check that verifiy the handle is the same as the one currently associated with the domain. Yeah, i'll add that! Forgot that it still applies. thanks -- Marc-André Lureau -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-glib] Add API to redefine an existing domain
From: Zeeshan Ali (Khattak) zeesha...@gnome.org --- libvirt-gobject/libvirt-gobject-domain.c | 63 ++ libvirt-gobject/libvirt-gobject-domain.h |3 + libvirt-gobject/libvirt-gobject.sym |1 + 3 files changed, 67 insertions(+), 0 deletions(-) diff --git a/libvirt-gobject/libvirt-gobject-domain.c b/libvirt-gobject/libvirt-gobject-domain.c index 1fa27bd..a198715 100644 --- a/libvirt-gobject/libvirt-gobject-domain.c +++ b/libvirt-gobject/libvirt-gobject-domain.c @@ -449,6 +449,69 @@ GVirConfigDomain *gvir_domain_get_config(GVirDomain *dom, return conf; } +/** + * gvir_domain_set_config: + * @domain: the domain + * @conf: the new configuration for the domain + * @err: (allow-none): Place-holder for error or NULL + * + * Resets configuration of an existing domain. + * + * Note: If domain is already running, the new configuration will not take + * affect until domain reboots. + * + * Returns: TRUE on success, FALSE if an error occurred. + */ +gboolean gvir_domain_set_config(GVirDomain *domain, +GVirConfigDomain *conf, +GError **err) +{ +const gchar *xml; +virConnectPtr conn; +virDomainPtr handle; +gchar uuid[VIR_UUID_STRING_BUFLEN]; +GVirDomainPrivate *priv = domain-priv; + +g_return_val_if_fail(GVIR_IS_DOMAIN (domain), FALSE); +g_return_val_if_fail(GVIR_IS_CONFIG_DOMAIN (conf), FALSE); +g_return_val_if_fail(err == NULL || *err == NULL, FALSE); + +xml = gvir_config_object_to_xml(GVIR_CONFIG_OBJECT(conf)); + +g_return_val_if_fail(xml != NULL, FALSE); + +if ((conn = virDomainGetConnect(priv-handle)) == NULL) { +if (err != NULL) +*err = gvir_error_new_literal(GVIR_DOMAIN_ERROR, + 0, + Failed to get domain connection); +return FALSE; +} + +handle = virDomainDefineXML(conn, xml); + +if (handle == NULL) { +if (err != NULL) +*err = gvir_error_new_literal(GVIR_DOMAIN_ERROR, + 0, + Failed to set + domain configuration); +return FALSE; +} + +virDomainGetUUIDString(priv-handle, uuid); + +if (strcmp (uuid, priv-uuid) != 0) { +if (err != NULL) +*err = gvir_error_new_literal(GVIR_DOMAIN_ERROR, + 0, + Failed to set + domain configuration); +return FALSE; +} + +return TRUE; +} /** * gvir_domain_get_info: diff --git a/libvirt-gobject/libvirt-gobject-domain.h b/libvirt-gobject/libvirt-gobject-domain.h index 94bd53e..0479de8 100644 --- a/libvirt-gobject/libvirt-gobject-domain.h +++ b/libvirt-gobject/libvirt-gobject-domain.h @@ -123,6 +123,9 @@ GVirDomainInfo *gvir_domain_get_info(GVirDomain *dom, GVirConfigDomain *gvir_domain_get_config(GVirDomain *dom, guint64 flags, GError **err); +gboolean gvir_domain_set_config(GVirDomain *domain, +GVirConfigDomain *conf, +GError **err); gchar *gvir_domain_screenshot(GVirDomain *dom, GVirStream *stream, diff --git a/libvirt-gobject/libvirt-gobject.sym b/libvirt-gobject/libvirt-gobject.sym index 164b6b8..46c53f9 100644 --- a/libvirt-gobject/libvirt-gobject.sym +++ b/libvirt-gobject/libvirt-gobject.sym @@ -53,6 +53,7 @@ LIBVIRT_GOBJECT_0.0.1 { gvir_domain_shutdown; gvir_domain_reboot; gvir_domain_get_config; + gvir_domain_set_config; gvir_domain_get_info; gvir_domain_screenshot; -- 1.7.7.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [libvirt-glib] Add API to redefine an existing domain
On Mon, Nov 21, 2011 at 9:58 PM, Marc-André Lureau marcandre.lur...@gmail.com wrote: On Mon, Nov 21, 2011 at 8:45 PM, Zeeshan Ali (Khattak) zeesha...@gnome.org wrote: Sorry, i don't get it. Verify how? By doing what I proposed bellow, reading libvirt code, ask on libvirt list/maintainers, test etc.. Ah that, yeah i already did that. Patching coming.. -- Regards, Zeeshan Ali (Khattak) FSF member#5124 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [libvirt-glib] Add API to redefine an existing domain
On Mon, Nov 21, 2011 at 9:02 PM, Zeeshan Ali (Khattak) zeesha...@gnome.org wrote: + g_return_val_if_fail(err == NULL || *err == NULL, FALSE); this needs update, as I wrote before. + xml = gvir_config_object_to_xml(GVIR_CONFIG_OBJECT(conf)); hmm, don't we need to free xml? + virDomainGetUUIDString(priv-handle, uuid); + + if (strcmp (uuid, priv-uuid) != 0) { + if (err != NULL) + *err = gvir_error_new_literal(GVIR_DOMAIN_ERROR, I prefer g_strcmp0, because it's safer. But the main issue is that you don't say clearly if we can safely ignore that new handle, at the very least if there is no leakage. A comment in the code would be welcome. regards -- Marc-André Lureau -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-glib] Add API to redefine an existing domain
From: Zeeshan Ali (Khattak) zeesha...@gnome.org --- libvirt-gobject/libvirt-gobject-domain.c | 65 ++ libvirt-gobject/libvirt-gobject-domain.h |3 + libvirt-gobject/libvirt-gobject.sym |1 + 3 files changed, 69 insertions(+), 0 deletions(-) diff --git a/libvirt-gobject/libvirt-gobject-domain.c b/libvirt-gobject/libvirt-gobject-domain.c index 1fa27bd..7121a21 100644 --- a/libvirt-gobject/libvirt-gobject-domain.c +++ b/libvirt-gobject/libvirt-gobject-domain.c @@ -449,6 +449,71 @@ GVirConfigDomain *gvir_domain_get_config(GVirDomain *dom, return conf; } +/** + * gvir_domain_set_config: + * @domain: the domain + * @conf: the new configuration for the domain + * @err: (allow-none): Place-holder for error or NULL + * + * Resets configuration of an existing domain. + * + * Note: If domain is already running, the new configuration will not take + * affect until domain reboots. + * + * Returns: TRUE on success, FALSE if an error occurred. + */ +gboolean gvir_domain_set_config(GVirDomain *domain, +GVirConfigDomain *conf, +GError **err) +{ +const gchar *xml; +virConnectPtr conn; +virDomainPtr handle; +gchar uuid[VIR_UUID_STRING_BUFLEN]; +GVirDomainPrivate *priv = domain-priv; + +g_return_val_if_fail(GVIR_IS_DOMAIN (domain), FALSE); +g_return_val_if_fail(GVIR_IS_CONFIG_DOMAIN (conf), FALSE); +g_return_val_if_fail(err == NULL || *err == NULL, FALSE); + +xml = gvir_config_object_to_xml(GVIR_CONFIG_OBJECT(conf)); + +g_return_val_if_fail(xml != NULL, FALSE); + +if ((conn = virDomainGetConnect(priv-handle)) == NULL) { +if (err != NULL) +*err = gvir_error_new_literal(GVIR_DOMAIN_ERROR, + 0, + Failed to get domain connection); +return FALSE; +} + +handle = virDomainDefineXML(conn, xml); + +if (handle == NULL) { +if (err != NULL) +*err = gvir_error_new_literal(GVIR_DOMAIN_ERROR, + 0, + Failed to set + domain configuration); +return FALSE; +} + +virDomainGetUUIDString(handle, uuid); +virDomainFree(handle); + +if (g_strcmp0 (uuid, priv-uuid) != 0) { +if (err != NULL) +*err = gvir_error_new_literal(GVIR_DOMAIN_ERROR, + 0, + Failed to set + domain configuration); + +return FALSE; +} + +return TRUE; +} /** * gvir_domain_get_info: diff --git a/libvirt-gobject/libvirt-gobject-domain.h b/libvirt-gobject/libvirt-gobject-domain.h index 94bd53e..0479de8 100644 --- a/libvirt-gobject/libvirt-gobject-domain.h +++ b/libvirt-gobject/libvirt-gobject-domain.h @@ -123,6 +123,9 @@ GVirDomainInfo *gvir_domain_get_info(GVirDomain *dom, GVirConfigDomain *gvir_domain_get_config(GVirDomain *dom, guint64 flags, GError **err); +gboolean gvir_domain_set_config(GVirDomain *domain, +GVirConfigDomain *conf, +GError **err); gchar *gvir_domain_screenshot(GVirDomain *dom, GVirStream *stream, diff --git a/libvirt-gobject/libvirt-gobject.sym b/libvirt-gobject/libvirt-gobject.sym index 164b6b8..46c53f9 100644 --- a/libvirt-gobject/libvirt-gobject.sym +++ b/libvirt-gobject/libvirt-gobject.sym @@ -53,6 +53,7 @@ LIBVIRT_GOBJECT_0.0.1 { gvir_domain_shutdown; gvir_domain_reboot; gvir_domain_get_config; + gvir_domain_set_config; gvir_domain_get_info; gvir_domain_screenshot; -- 1.7.7.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 1/2] nwfilter: use shell variable to invoke 'ebtables' command
On 11/21/2011 06:27 AM, Stefan Berger wrote: Introduce a shell variable 'EBT' to invoke the ebtables command. Hard-code the used ebtables table to '-t nat'. Tested with libvirt-tck. @@ -2967,11 +2964,11 @@ _ebtablesRemoveSubChains(virBufferPtr bu char rootchain[MAX_CHAINNAME_LENGTH]; unsigned i; +NWFILTER_SET_EBTABLES_SHELLVAR(buf); + virBufferAsprintf(buf, NWFILTER_FUNC_COLLECT_CHAINS, - ebtables_cmd_path, EBTABLES_DEFAULT_TABLE, chains); -virBufferAsprintf(buf, NWFILTER_FUNC_RM_CHAINS, - ebtables_cmd_path, EBTABLES_DEFAULT_TABLE, - ebtables_cmd_path, EBTABLES_DEFAULT_TABLE); + chains); +virBufferAdd(buf, NWFILTER_FUNC_RM_CHAINS, -1); If I'm not mistaken, virBufferAddLit() should work here, since NWFILTER_FUNC_FM_CHAINS is a macro for a string literal; but since 'make syntax-check' can't see through macros, you can get away with this as-is. ACK, looks like you caught all the places that need it. -- Eric Blake ebl...@redhat.com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 2/2] nwfilter: use shell variable to invoke 'ip(6)tables' command
On 11/21/2011 06:28 AM, Stefan Berger wrote: Introduce a shell variable 'IBT' to invoke the ip(6)tables command. Tested with libvirt-tck. --- src/nwfilter/nwfilter_ebiptables_driver.c | 313 ++ 1 file changed, 155 insertions(+), 158 deletions(-) Index: libvirt-acl/src/nwfilter/nwfilter_ebiptables_driver.c === --- libvirt-acl.orig/src/nwfilter/nwfilter_ebiptables_driver.c +++ libvirt-acl/src/nwfilter/nwfilter_ebiptables_driver.c @@ -146,6 +146,10 @@ static const char ebiptables_script_set_ #define NWFILTER_SET_EBTABLES_SHELLVAR(BUFPTR) \ virBufferAsprintf(BUFPTR, EBT=%s\n, ebtables_cmd_path); These variable assignments will fail if the absolute path to ebtables_cmd_path and friends contain any whitespace or shell metacharacters, but then again, the old code pre-conversion would have failed in similar manners, so we already had an implicit assumption that the user isn't calling ./configure with an insane PATH containing a directory with whitespace at the front as the location for their preferred commands. I see nothing wrong with continuing that assumption, although someday we may want to make configure fail if it detects a tool name that cannot be safely passed unquoted through shell (at least, for the three tools mentioned in this .c file where we are using the shell), as a safety valve in the interim of us ever making the much bigger change of avoiding shell in the first place. ACK as-is. -- Eric Blake ebl...@redhat.com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [libvirt-glib] Add API to redefine an existing domain
On Mon, Nov 21, 2011 at 10:12 PM, Marc-André Lureau marcandre.lur...@gmail.com wrote: On Mon, Nov 21, 2011 at 9:02 PM, Zeeshan Ali (Khattak) zeesha...@gnome.org wrote: + g_return_val_if_fail(err == NULL || *err == NULL, FALSE); As I explained on IRC, it is justified AFAICT. Either you pass a 'NULL' as the error arg or you pass an uninitialized place-holder for error. Fixed other issues you pointed to. -- Regards, Zeeshan Ali (Khattak) FSF member#5124 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-glib] Add API to redefine an existing domain
From: Zeeshan Ali (Khattak) zeesha...@gnome.org --- libvirt-gobject/libvirt-gobject-domain.c | 68 ++ libvirt-gobject/libvirt-gobject-domain.h |3 + libvirt-gobject/libvirt-gobject.sym |1 + 3 files changed, 72 insertions(+), 0 deletions(-) diff --git a/libvirt-gobject/libvirt-gobject-domain.c b/libvirt-gobject/libvirt-gobject-domain.c index 1fa27bd..7ff820b 100644 --- a/libvirt-gobject/libvirt-gobject-domain.c +++ b/libvirt-gobject/libvirt-gobject-domain.c @@ -449,6 +449,74 @@ GVirConfigDomain *gvir_domain_get_config(GVirDomain *dom, return conf; } +/** + * gvir_domain_set_config: + * @domain: the domain + * @conf: the new configuration for the domain + * @err: (allow-none): Place-holder for error or NULL + * + * Resets configuration of an existing domain. + * + * Note: If domain is already running, the new configuration will not take + * affect until domain reboots. + * + * Returns: TRUE on success, FALSE if an error occurred. + */ +gboolean gvir_domain_set_config(GVirDomain *domain, +GVirConfigDomain *conf, +GError **err) +{ +gchar *xml; +virConnectPtr conn; +virDomainPtr handle; +gchar uuid[VIR_UUID_STRING_BUFLEN]; +GVirDomainPrivate *priv = domain-priv; + +g_return_val_if_fail(GVIR_IS_DOMAIN (domain), FALSE); +g_return_val_if_fail(GVIR_IS_CONFIG_DOMAIN (conf), FALSE); +g_return_val_if_fail(err == NULL || *err == NULL, FALSE); + +xml = gvir_config_object_to_xml(GVIR_CONFIG_OBJECT(conf)); + +g_return_val_if_fail(xml != NULL, FALSE); + +if ((conn = virDomainGetConnect(priv-handle)) == NULL) { +if (err != NULL) +*err = gvir_error_new_literal(GVIR_DOMAIN_ERROR, + 0, + Failed to get domain connection); +g_free (xml); + +return FALSE; +} + +handle = virDomainDefineXML(conn, xml); +g_free (xml); + +if (handle == NULL) { +if (err != NULL) +*err = gvir_error_new_literal(GVIR_DOMAIN_ERROR, + 0, + Failed to set + domain configuration); +return FALSE; +} + +virDomainGetUUIDString(handle, uuid); +virDomainFree(handle); + +if (g_strcmp0 (uuid, priv-uuid) != 0) { +if (err != NULL) +*err = gvir_error_new_literal(GVIR_DOMAIN_ERROR, + 0, + Failed to set + domain configuration); + +return FALSE; +} + +return TRUE; +} /** * gvir_domain_get_info: diff --git a/libvirt-gobject/libvirt-gobject-domain.h b/libvirt-gobject/libvirt-gobject-domain.h index 94bd53e..0479de8 100644 --- a/libvirt-gobject/libvirt-gobject-domain.h +++ b/libvirt-gobject/libvirt-gobject-domain.h @@ -123,6 +123,9 @@ GVirDomainInfo *gvir_domain_get_info(GVirDomain *dom, GVirConfigDomain *gvir_domain_get_config(GVirDomain *dom, guint64 flags, GError **err); +gboolean gvir_domain_set_config(GVirDomain *domain, +GVirConfigDomain *conf, +GError **err); gchar *gvir_domain_screenshot(GVirDomain *dom, GVirStream *stream, diff --git a/libvirt-gobject/libvirt-gobject.sym b/libvirt-gobject/libvirt-gobject.sym index 164b6b8..46c53f9 100644 --- a/libvirt-gobject/libvirt-gobject.sym +++ b/libvirt-gobject/libvirt-gobject.sym @@ -53,6 +53,7 @@ LIBVIRT_GOBJECT_0.0.1 { gvir_domain_shutdown; gvir_domain_reboot; gvir_domain_get_config; + gvir_domain_set_config; gvir_domain_get_info; gvir_domain_screenshot; -- 1.7.7.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [libvirt-glib] Add API to redefine an existing domain
On Mon, Nov 21, 2011 at 10:09 PM, Zeeshan Ali (Khattak) zeesha...@gnome.org wrote: As I explained on IRC, it is justified AFAICT. Either you pass a 'NULL' as the error arg or you pass an uninitialized place-holder for error. right, sorry for the confusion -- Marc-André Lureau -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] Bug Fix: Do not release network actual device in qemuBuildCommandLine on error
That's a long subject line; I shortened it to: qemu: don't release network actual device twice On 11/16/2011 07:34 PM, Roopa Prabhu wrote: From: Roopa Prabhu ropra...@cisco.com For direct attach devices, in qemuBuildCommandLine, we seem to be freeing actual device on error path (with networkReleaseActualDevice). But the actual device is not deleted. qemuProcessStop eventually deletes the direct attach device and releases actual device. But by the time qemuProcessStop is called qemuBuildCommandLine has already freed actual device. Leaving stray macvtap devices behind on error. So the simplest fix is to remove the networkReleaseActualDevice in qemuBuildCommandLine. This patch does just that. Does this look right ?. I have only verified this with direct and bridge mode. as well as filtering the uncertainty out of the commit message. The other option is to do both delMacvtap and networkReleaseActualDevice in qemuBuildCommandLine instead of doing only networkReleaseActualDevice. I do have a patch for this too. Signed-off-by: Roopa Prabhu ropra...@cisco.com --- src/qemu/qemu_command.c |2 -- 1 files changed, 0 insertions(+), 2 deletions(-) Given Stefan's testing, ACK and pushed with commit message modified per above. -- Eric Blake ebl...@redhat.com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCHv3] conf: don't modify cpu set string during parsing
On 11/18/2011 09:41 PM, Bharata B Rao wrote: On Fri, Nov 18, 2011 at 11:31:12AM -0700, Eric Blake wrote: None of the callers cared if str was updated to point to the next byte after the parsed cpuset; simplifying this results in quite a few code simplifications. Additionally, virCPUDefParseXML was strdup()'ing a malloc()'d string; avoiding a memory copy resulted in less code. Changes to virCPUDefParseXML look good. numa ... /numa XML section is parsed correctly and qemu -numa options are generated correctly after this change. Thanks for the review; I've pushed this patch now. -- Eric Blake ebl...@redhat.com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [libvirt-glib] Add API to redefine an existing domain
ack On Mon, Nov 21, 2011 at 10:10 PM, Zeeshan Ali (Khattak) zeesha...@gnome.org wrote: From: Zeeshan Ali (Khattak) zeesha...@gnome.org --- libvirt-gobject/libvirt-gobject-domain.c | 68 ++ libvirt-gobject/libvirt-gobject-domain.h | 3 + libvirt-gobject/libvirt-gobject.sym | 1 + 3 files changed, 72 insertions(+), 0 deletions(-) diff --git a/libvirt-gobject/libvirt-gobject-domain.c b/libvirt-gobject/libvirt-gobject-domain.c index 1fa27bd..7ff820b 100644 --- a/libvirt-gobject/libvirt-gobject-domain.c +++ b/libvirt-gobject/libvirt-gobject-domain.c @@ -449,6 +449,74 @@ GVirConfigDomain *gvir_domain_get_config(GVirDomain *dom, return conf; } +/** + * gvir_domain_set_config: + * @domain: the domain + * @conf: the new configuration for the domain + * @err: (allow-none): Place-holder for error or NULL + * + * Resets configuration of an existing domain. + * + * Note: If domain is already running, the new configuration will not take + * affect until domain reboots. + * + * Returns: TRUE on success, FALSE if an error occurred. + */ +gboolean gvir_domain_set_config(GVirDomain *domain, + GVirConfigDomain *conf, + GError **err) +{ + gchar *xml; + virConnectPtr conn; + virDomainPtr handle; + gchar uuid[VIR_UUID_STRING_BUFLEN]; + GVirDomainPrivate *priv = domain-priv; + + g_return_val_if_fail(GVIR_IS_DOMAIN (domain), FALSE); + g_return_val_if_fail(GVIR_IS_CONFIG_DOMAIN (conf), FALSE); + g_return_val_if_fail(err == NULL || *err == NULL, FALSE); + + xml = gvir_config_object_to_xml(GVIR_CONFIG_OBJECT(conf)); + + g_return_val_if_fail(xml != NULL, FALSE); + + if ((conn = virDomainGetConnect(priv-handle)) == NULL) { + if (err != NULL) + *err = gvir_error_new_literal(GVIR_DOMAIN_ERROR, + 0, + Failed to get domain connection); + g_free (xml); + + return FALSE; + } + + handle = virDomainDefineXML(conn, xml); + g_free (xml); + + if (handle == NULL) { + if (err != NULL) + *err = gvir_error_new_literal(GVIR_DOMAIN_ERROR, + 0, + Failed to set + domain configuration); + return FALSE; + } + + virDomainGetUUIDString(handle, uuid); + virDomainFree(handle); + + if (g_strcmp0 (uuid, priv-uuid) != 0) { + if (err != NULL) + *err = gvir_error_new_literal(GVIR_DOMAIN_ERROR, + 0, + Failed to set + domain configuration); + + return FALSE; + } + + return TRUE; +} /** * gvir_domain_get_info: diff --git a/libvirt-gobject/libvirt-gobject-domain.h b/libvirt-gobject/libvirt-gobject-domain.h index 94bd53e..0479de8 100644 --- a/libvirt-gobject/libvirt-gobject-domain.h +++ b/libvirt-gobject/libvirt-gobject-domain.h @@ -123,6 +123,9 @@ GVirDomainInfo *gvir_domain_get_info(GVirDomain *dom, GVirConfigDomain *gvir_domain_get_config(GVirDomain *dom, guint64 flags, GError **err); +gboolean gvir_domain_set_config(GVirDomain *domain, + GVirConfigDomain *conf, + GError **err); gchar *gvir_domain_screenshot(GVirDomain *dom, GVirStream *stream, diff --git a/libvirt-gobject/libvirt-gobject.sym b/libvirt-gobject/libvirt-gobject.sym index 164b6b8..46c53f9 100644 --- a/libvirt-gobject/libvirt-gobject.sym +++ b/libvirt-gobject/libvirt-gobject.sym @@ -53,6 +53,7 @@ LIBVIRT_GOBJECT_0.0.1 { gvir_domain_shutdown; gvir_domain_reboot; gvir_domain_get_config; + gvir_domain_set_config; gvir_domain_get_info; gvir_domain_screenshot; -- 1.7.7.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list -- Marc-André Lureau -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH V1 4/9] Add a mac chain
On 10/26/2011 09:12 AM, Stefan Berger wrote: With hunks borrowed from one of David Steven's previous patches, we now add the capability of having a 'mac' chain which is useful to filter for multiple valid MAC addresses. Signed-off-by: David L Stevens dlstev...@us.ibm.com Signed-off-by: Stefan Berger stef...@linux.vnet.ibm.com +char protostr[16] = { 0, }; A bit oversized... PRINT_ROOT_CHAIN(rootchain, chainPrefix, ifname); PRINT_CHAIN(chain, chainPrefix, ifname, (filtername) ? filtername : l3_protocols[protoidx].val); +switch (protoidx) { +case L2_PROTO_MAC_IDX: +break; +default: +snprintf(protostr, sizeof(protostr), -p 0x%04x , for a max of 11 bytes (including trailing NUL) ever printed into it, but not the end of the world. And since you didn't check snprintf results for failure, if we ever change the size of protostr or the length of what we print into it, it's a slight maintenance risk we are taking on, compared to dynamic allocation that always gets the right length. But I don't know if it is worth replacing this snprintf with virAsprintf/VIR_FREE overhead, so I can live with it as is. @@ -2918,7 +2930,7 @@ ebtablesCreateTmpSubChain(ebiptablesRule CMD_DEF(%s -t %s -N %s) CMD_SEPARATOR CMD_EXEC %s - CMD_DEF(%s -t %s -%%c %s %%s -p 0x%x -j %s) + CMD_DEF(%s -t %s -%%c %s %%s %s -j %s) This results in output with a double space, either: ...%s -j ... or ...%s -p 0x -j ... Also not the end of the world, but you may want to remove the extra space before the -j. ACK. There is some conflict resolution needed in nwfilter.rng, but that should be trivial. -- Eric Blake ebl...@redhat.com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH V1 5/9] Add support for STP filtering
On 10/26/2011 09:12 AM, Stefan Berger wrote: This patch adds support for filtering of STP (spanning tree protocol) traffic to the parser and makes us of the ebtables support for STP filtering. This code now enables the filtering of traffic in chains with prefix 'stp'. Signed-off-by: Stefan Berger stef...@linux.vnet.ibm.com --- docs/schemas/nwfilter.rng | 154 + src/conf/nwfilter_conf.c | 178 ++ src/conf/nwfilter_conf.h | 41 ++ src/libvirt_private.syms |1 src/nwfilter/nwfilter_ebiptables_driver.c | 90 +++ 5 files changed, 461 insertions(+), 3 deletions(-) Some conflict resolution, again in the rng, and also in context for nwfilter_conf.c, but should be trivial. You already pre-emptively mentioned STP chains in an earlier patch, and I see the title of 7/9 mentions more about STP documentation, so I'll assume that between those two, the new .rng additions are properly documented. @@ -1047,6 +1049,136 @@ static const virXMLAttr2Struct vlanAttri } }; +static const virXMLAttr2Struct stpAttributes[] = { +/* spanning tree uses a special destination MAC address */ +{ +.name = SRCMACADDR, +.datatype = DATATYPE_MACADDR, +.dataIdx = offsetof(virNWFilterRuleDef, +p.stpHdrFilter.ethHdr.dataSrcMACAddr), +}, +{ +.name = forward-delay-hi, +.datatype = DATATYPE_UINT16 | DATATYPE_UINT16_HEX, +.dataIdx = offsetof(virNWFilterRuleDef, p.stpHdrFilter.dataFwdDelayHi), +}, +COMMENT_PROP(stpHdrFilter), I'm assuming this is an accurate layout mapping the on-the-wire struct to named fields for reference in XML attributes, although I didn't actually go hunt down an RFC to verify. Perhaps a comment pointing tot the STP RFC might prove handy. @@ -2979,6 +3149,14 @@ virNWFilterRuleDefDetailsFormat(virBuffe item-u.u16); break; + case DATATYPE_UINT32_HEX: + asHex = true; + /* fallthrough */ + case DATATYPE_UINT32: + virBufferAsprintf(buf, asHex ? 0x%x : %d, + item-u.u32); %u, not %d. Otherwise you introduce a spurious negative sign on values with the most-significant-bit set. Also, I'm not entirely sure whether %u and uint32_t always match, or if there are some 32-bit platforms where uint32_t is long and this would trigger a type mismatch warning from gcc. On the other hand, this code only compiles on Linux where we know uint32_t is always int; using inttypes.h for PRIu32 would be more portable, but that's a separate cleanup. @@ -290,6 +292,16 @@ _printDataType(virNWFilterVarCombIterPtr } break; +case DATATYPE_UINT32: +case DATATYPE_UINT32_HEX: +if (snprintf(buf, bufsize, asHex ? 0x%x : %d, + item-u.u32) = bufsize) { +virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, %s, + _(Buffer too small for uint32 type)); Again, %u, not %d. Also, this code tends to be called with a hard-coded allocation of 'number[20];', which is sufficient for uint32_t, but not long enough if we ever expand to DATATYPE_UINT64. I'm wondering if we should use intprops.h from gnulib, for the INT_BUFSIZE_BOUND() macro, rather than a hard-coded 20. But at least this snprintf usage checked for error (I noticed in 4/9 that you used snprintf without error checking). +return 1; Looks like this is code addition to an existing function with positive 1 return convention, so you can defer changing it to -1 until a later patch that cleans up the entire function (I'm only worried about completely new functions introduced by this patch). +case VIR_NWFILTER_RULE_PROTOCOL_STP: + +/* cannot handle inout direction with srcmask set in reverse dir. + since this clashes with -d below... */ +if (reverse +HAS_ENTRY_ITEM(rule-p.stpHdrFilter.ethHdr.dataSrcMACAddr)) { +virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, + _(STP filtering in %s direction with + source MAC address set is not supported), + virNWFilterRuleDirectionTypeToString( + VIR_NWFILTER_RULE_DIRECTION_INOUT)); +return -1; +} + +virBufferAsprintf(buf, + CMD_DEF_PRE %s -t %s -%%c %s %%s, + ebtables_cmd_path, EBTABLES_DEFAULT_TABLE, chain); Looks like you've got some rebasing to do, depending on whether you push this or your env-var cleanup first. @@ -2907,7 +2992,7 @@ ebtablesCreateTmpSubChain(ebiptablesRule char
Re: [libvirt] [PATCH V1 6/9] Add test cases for STP traffic filtering
On 10/26/2011 09:12 AM, Stefan Berger wrote: This patch adds a few test cases for the XML parsing of STP filtering nodes. Signed-off-by: Stefan Berger stef...@linux.vnet.ibm.com --- tests/nwfilterxml2xmlin/stp-test.xml | 26 ++ tests/nwfilterxml2xmlout/stp-test.xml | 12 tests/nwfilterxml2xmltest.c |1 + 3 files changed, 39 insertions(+) Looks good. ACK. + rule action='reject' direction='in' + stp srcmacaddr='1:2:3:4:5:6' srcmacmask='ff:ff:ff:ff:ff:ff' + sender-priority='0x1234' + sender-address=6:5:4:3:2:1 + port='123' port-hi='234' + age='5544' age-hi='' + max-age='' max-age-hi='' + hello-time='12345' hello-time-hi='12346' + forward-delay='54321' forward-delay-hi='65432'/ That's a lot of attributes for one element, thankfully we can split it over multiple lines. -- Eric Blake ebl...@redhat.com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH V1 8/9] [RFC] New filters to handle multiple IP addresses
On 10/26/2011 09:12 AM, Stefan Berger wrote: With new filters borrowed from David Steven's submission: A set of new filters to handle multiple IP addresses and MAC addresses per interface. The alternative would be to replace some of the existing ones with these here. On IRC, you mentioned that you were dropping this, so I haven't bothered to review it. -- Eric Blake ebl...@redhat.com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH V1 7/9] Add documentation for STP filtering support
On 10/26/2011 09:12 AM, Stefan Berger wrote: Add documentation for the STP filtering support. Describe the XML attributes that are supported. Signed-off-by: Stefan Berger stef...@linux.vnet.ibm.com --- docs/formatnwfilter.html.in | 142 1 file changed, 142 insertions(+) Index: libvirt-acl/docs/formatnwfilter.html.in === --- libvirt-acl.orig/docs/formatnwfilter.html.in +++ libvirt-acl/docs/formatnwfilter.html.in @@ -467,6 +467,148 @@ Valid Strings for codeencap-protocol/code are: arp, ipv4, ipv6 /p +h5a name=nwfelemsRulesProtoSTPSTP (Spanning Tree Protocol)/a + span class=since(Since 0.9.7)/span 0.9.8, now. +/h5 +p + Protocol ID: codestp/code + br/ + Note: Rules of this type should go eitherinto the coderoot/code or s/eitherinto/either into/ ACK with those nits fixed. -- Eric Blake ebl...@redhat.com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH V1 9/9] Improve error reporting of failures to apply filtering rules
On 10/26/2011 09:12 AM, Stefan Berger wrote: Display the executed command and failure message if a command failed to execute. Signed-off-by: Stefan Berger stef...@linux.vnet.ibm.com --- src/nwfilter/nwfilter_ebiptables_driver.c | 82 ++ 1 file changed, 50 insertions(+), 32 deletions(-) Index: libvirt-acl/src/nwfilter/nwfilter_ebiptables_driver.c === --- libvirt-acl.orig/src/nwfilter/nwfilter_ebiptables_driver.c +++ libvirt-acl/src/nwfilter/nwfilter_ebiptables_driver.c @@ -63,10 +63,10 @@ #define CMD_DEF_PRE cmd=' #define CMD_DEF_POST ' #define CMD_DEF(X) CMD_DEF_PRE X CMD_DEF_POST -#define CMD_EXEC eval res=\\$\\(\${cmd}\\\) CMD_SEPARATOR +#define CMD_EXEC eval res=\\$\\(\${cmd} 21 \\\) CMD_SEPARATOR Okay, after turning the C literal into shell, you have: eval res=\$\(${cmd} 21 \) and after the shell eval, you have: res=$(command 21 ) That space after '21' could be deleted, but it doesn't hurt to leave it in. #define CMD_STOPONERR(X) \ X ? if [ $? -ne 0 ]; then \ - echo \Failure to execute command '${cmd}'.\; \ + echo \Failure to execute command '${cmd}' : '${res}'.\; \ Yes, this is a bit more informative. exit 1; \ fi CMD_SEPARATOR \ : @@ -2785,12 +2785,16 @@ err_exit: */ static int ebiptablesExecCLI(virBufferPtr buf, - int *status) + int *status, char **errbuf) { char *cmds; char *filename; int rc; const char *argv[] = {NULL, NULL}; +virCommandPtr cmd; + +if (errbuf) +VIR_FREE(*errbuf); This has merge conflicts with existing patches that went in during the meantime. I'd feel better seeing a v2 to verify proper rebasing. if (virBufferError(buf)) { virReportOOMError(); @@ -2817,7 +2821,13 @@ ebiptablesExecCLI(virBufferPtr buf, virMutexLock(execCLIMutex); -rc = virRun(argv, status); +cmd = virCommandNewArgs(argv); +if (errbuf) +virCommandSetOutputBuffer(cmd, errbuf); It looks a bit odd calling it errbuf, when it is the output collected from stdout; perhaps calling it outbuf would make more sense. @@ -3285,7 +3297,7 @@ ebtablesApplyBasicRules(const char *ifna ebtablesLinkTmpRootChain(buf, 1, ifname, 1); ebtablesRenameTmpRootChain(buf, 1, ifname); -if (ebiptablesExecCLI(buf, cli_status) || cli_status != 0) +if (ebiptablesExecCLI(buf, cli_status, NULL) || cli_status != 0) You know, as long as we are cleaning things up, you could pass NULL instead of cli_status to enforce that the command has a 0 exit status, so that you trim lines like this to: if (ebiptablesExecCLI(buf, NULL, NULL) 0) @@ -3874,12 +3889,13 @@ tear_down_tmpebchains: ebtablesRemoveTmpRootChain(buf, 0, ifname); } -ebiptablesExecCLI(buf, cli_status); +ebiptablesExecCLI(buf, cli_status, NULL); virNWFilterReportError(VIR_ERR_BUILD_FIREWALL, _(Some rules could not be created for - interface %s.), - ifname); + interface %s : %s), + ifname, + errmsg ? errmsg : ); That outputs a trailing space if there was no error message. Better might be: virNWFilterReportError(VIR_ERR_BUILD_FIREWALL, _(Some rules could not be created for interface %s%s%s), ifname, errmsg ? : : , errmsg ? errmsg : ); Alas, we have an i18n nightmare. errmsg contains English text output by the shell script, which is not marked for translation by either the shell script (which itself is tricky - witness the libvirt-guests init script) nor for translation in the C code that generated the shell script. Meanwhile, since we didn't call virCommandAddEnvPassCommon() to set the virCommand to force LC_ALL=C, that means we passed the libvirtd setting of LC_MESSAGES on through to the child processes, such that sh and ebtables output might also be translated. For an example, that means someone using LC_MESSAGES=es_ES.UTF-8 could see: Algunas reglas no han podido crearse para la interfaz eth0 : Failure to execute command '/path/to/ebtables -t nat ...' : /bin/sh: /path/to/ebtables: no se encontró la orden That's a nasty mix of native/English/native output all in one very long message. Maybe we should be rethinking the desired output format a bit, for the sake of generating properly translated messages? Even breaking things into multiple messages, so that each message is either translated or English, rather than mixed, might help. Is it worth trying to fix part of the translation issue, by defining CMD_STOPONERROR to something that outputs the results of _(Failure to execute command '%s'), then
Re: [libvirt] Bug 754974 - connection with xen+ssh vm's are missing with list (virsh)
On 11/18/2011 07:25 AM, Robin van Leeuwen wrote: Hi I posted the above mentioned bug to Bugzilla and one reply said to mention it on libvir-list@redhat.com as well. So here it is: https://bugzilla.redhat.com/show_bug.cgi?id=754974 Is mentioning it in this list too, (when it involves libvirt offcourse) after filing a bug on Bugzilla, the appropiate action to take? You're doing fine. BZs tend to be a bit more permanent (they exist to remind us that the problem exists, and even after it exists), but they are also a bit harder to access so they tend to not get as rapid a response as an email to the list. Alas, regarding the bug itself, I'm not familiar enough with 'virsh list' on a xen:// connection to know how to suggest debugging things; perhaps someone else can chime in. The fact that a 'shut off' guest is listed both locally and remotely means your remote connection is working, while the 'running' and 'idle' Dom0 and guest 17 showing up only locally might point to a flaw in the remote implementation of listing active xen guests. -- Eric Blake ebl...@redhat.com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] virsh: add iface-bridge and iface-unbridge commands
On 11/18/2011 12:25 AM, Kashyap Chamarthy wrote: On 11/17/2011 02:35 AM, Laine Stump wrote: On 11/16/2011 01:50 PM, Eric Blake wrote: I'll live up to my well-earned reputation :), and request that you don't push this without first squashing in docs (but to soften the blow, here's my first cut at something you can squash in). ACK with above nits fixed and man page docs added. I squashed in your virsh.pod change (plus a couple additions), fixed the nits, and pushed. Thanks! P.S. to anyone who tries these commands - do us both a favor and run virsh iface-begin beforehand, then run virsh iface-commit only after you're sure it's done the right thing (otherwise run virsh iface-rollback or just reboot (I think I've just realized the just reboot part isn't working on F16 due to the conversion to systemd...) Laine, is there an srpm or something with the above fixes which I can use to do a quick libvirt scratch build and give it a whirl ? DV maintains hourly snapshots of libvirt.git, documented here: http://libvirt.org/downloads.html Those are tarballs rather than srpms. However, libvirt tarballs include a working libvirt.spec, so that you could unpack things, run ./configure, then 'make rpm' to give yourself a working srpm. I haven't tested this, but I think that also means you could use 'rpmbuild -ta libvirt-git-snapshot.tar.gz' and get rpms from that approach. -- Eric Blake ebl...@redhat.com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [RFC PATCH v2 1/4] PowerPC : Use Sysfs to gather host topology
On 11/14/2011 07:46 AM, Prerna Saxena wrote: From 9084802bdf7a2c10d6a913cb7dde001ab6ab3543 Mon Sep 17 00:00:00 2001 From: Prerna Saxena pre...@linux.vnet.ibm.com Date: Mon, 3 Oct 2011 05:45:30 -0700 Subject: [PATCH 1/4] Use sysfs to gather host topology, in place of /proc/cpuinfo Are we sure that sysfs has this information for all kernels as far back as RHEL 5? Or should this patch be doing conditionals; probing sysfs first but falling back to /proc/cpuinfo otherwise? I tried compiling things, but got this warning: nodeinfo.c: In function 'linuxNodeInfoCPUPopulate': nodeinfo.c:287:5: error: suggest parentheses around assignment used as truth value [-Werror=parentheses] nodeinfo.c:202:36: error: unused parameter 'need_hyperthreads' [-Werror=unused-parameter] and seeing other comments in this thread, I didn't review it very closely (this is more a chance to revive the thread after a week, to see if you are planning on a resubmission before we consider a freeze for 0.9.8). -- Eric Blake ebl...@redhat.com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 0/8 v5] Summary on block IO throttle
On 11/15/2011 02:02 AM, Lei Li wrote: Changes since V3 - Use virTypedParameterPtr instead of specific struct in libvirt pulic API. - Relevant changes to remote driver, qemu driver, python support and virsh. Hmm, you didn't summarize changes since v4. Sorry for not noticing the v5 a bit sooner (the thread is getting a bit long, so this got buried in my inbox). Hopefully we are closer to getting this applied; I'd certainly like to see it in 0.9.8. -- Eric Blake ebl...@redhat.com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH RESEND v5] Export KVM Host Power Management capabilities
On 11/13/2011 10:29 PM, Srivatsa S. Bhat wrote: On 11/09/2011 04:38 PM, Srivatsa S. Bhat wrote: This patch exports KVM Host Power Management capabilities as XML so that higher-level systems management software can make use of these features available in the host. Changelog: - This version v5: Some redundant error messages were removed and the code was streamlined. v4: http://www.redhat.com/archives/libvir-list/2011-August/msg00316.html v3: http://www.redhat.com/archives/libvir-list/2011-August/msg00282.html v2: http://www.redhat.com/archives/libvir-list/2011-August/msg00238.html v1: http://thread.gmane.org/gmane.comp.emulators.libvirt/40886 References: -- [1] http://www.redhat.com/archives/libvir-list/2011-August/msg00248.html [2] http://www.redhat.com/archives/libvir-list/2011-August/msg00302.html Signed-off-by: Srivatsa S. Bhat srivatsa.b...@linux.vnet.ibm.com Any suggestions/comments on this patch? As suggested in one of the earlier versions, I have posted the follow-on patchset to add libvirt APIs to invoke suspend/resume in-band, here: http://www.redhat.com/archives/libvir-list/2011-November/msg00381.html Apologies for the delays, but I'm finally getting around to reviewing this series, along with the v3 series to expose an API to control power management on the host. I promise to either apply both series as a unit in time for 0.9.8, or give further feedback on how to improve them in the next revision, but I think we're converging on a useful design to make it worth exposing this information. -- Eric Blake ebl...@redhat.com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v3 0/2] API to invoke S3/S4 on a host and also resume from within libvirt
On 11/09/2011 05:05 AM, Srivatsa S. Bhat wrote: (This patch is positioned to go in after the patch that exports the host power management capabilities as XML, posted in [4]) I'm now reviewing that patch along with this series; if we need another revision, it may be easiest to merge the three patches into a single series and title it v6, so that they are together in one thread. This patch adds a new API to put a host to a suspended state (either Suspend-to-RAM or Suspend-to-Disk) and setup a timed resume to get the host back online, from within libvirt. This uses the RTC wakeup mechanism to set up a timer alarm before suspending the host, so that in-band resume is facilitated by the firing of the RTC alarm, which wakes up the host. I'm not as familiar with S3/S4 as I would like to be - am I correct that RTC wakeup works for S3 (where the host is maintaining minimal power and can thus react to interrupts), but not S4 (where the host has flushed completely to disk and powers off, but resumes from the state on disk on next power on)? Or am I misunderstanding these two power-saving states? The decision to use the RTC Wakeup mechanism to resume the host from sleep was taken in [1]. An initial API was discussed in [2]. Some design ideas for the asynchronous mechanism implementation was discussed in [3]. v3: * Rebased to libvirt 0.9.7 * Added a check to see if alarmTime (suspend duration) is within an acceptable range. v2: * Added an init function which finds out if S3/S4 is supported by the host, upon the first request to suspend/hibernate. * Added synchronization/locking to ensure that only one suspend operation is active at a time. v1: http://www.redhat.com/archives/libvir-list/2011-September/msg00830.html v2: http://comments.gmane.org/gmane.comp.emulators.libvirt/46729 References: [1]. http://www.redhat.com/archives/libvir-list/2011-August/msg00327.html [2]. http://www.redhat.com/archives/libvir-list/2011-August/msg00248.html [3]. http://www.redhat.com/archives/libvir-list/2011-September/msg00438.html [4]. http://www.redhat.com/archives/libvir-list/2011-November/msg00378.html -- Eric Blake ebl...@redhat.com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCHv4 4/4] blkiotune: add qemu support for blkiotune.device_weight
On 11/15/2011 03:33 PM, Eric Blake wrote: On 11/15/2011 12:22 AM, Hu Tao wrote: On Mon, Nov 14, 2011 at 09:30:02PM -0700, Eric Blake wrote: From: Hu Tao hu...@cn.fujitsu.com Implement setting/getting per-device blkio weights in qemu, using the cgroups blkio.weight_device tunable. +/* deviceWeightStr in the form of /device/path,weight,/device/path,weight + * for example, /dev/disk/by-path/pci-:00:1f.2-scsi-0:0:0:0,800 + */ +static int +parseBlkioWeightDeviceStr(char *deviceWeightStr, + virBlkioDeviceWeightPtr *dw, int *size, + virCgroupPtr cgroup) Does more than the function name says. Would it be better to just do the parsing here, and set the cgroup values after parsing(see my comment to patch 3 for filtering out 0-weight when writing to xml): Either approach works for me (renaming this function more accurately so that the domain_conf never has 0-weight entries, or going with your improvements to allow 0-weight entries in the domain_conf def but not expose them in the XML). I guess whoever reviews this series can cast the deciding vote on which of the two approaches we commit. Ping - this series seems worth including in 0.9.8; can we get a third-party review? -- Eric Blake ebl...@redhat.com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v3 1/2] Implement the asynchronous suspend and RTC wakeup
On 11/09/2011 05:05 AM, Srivatsa S. Bhat wrote: Add the core functions that implement the functionality of the API. Suspend is done by using an asynchronous mechanism so that we can return the status to the caller successfully before the host gets suspended. This asynchronous operation is achieved by suspending the host in a separate thread of execution. To resume the host, an RTC alarm is set up (based on how long we want to suspend) before suspending the host. When this alarm fires, the host gets woken up. Signed-off-by: Srivatsa S. Bhat srivatsa.b...@linux.vnet.ibm.com --- include/libvirt/libvirt.h.in |5 + src/libvirt_private.syms |7 + src/nodeinfo.c | 220 ++ src/nodeinfo.h | 14 +++ src/qemu/qemu_driver.c |5 + src/util/threads-pthread.c | 17 +++ src/util/threads.h |1 It looks weird seeing a public change (include/libvirt/libvirt.h.in) mixed in with a driver-specific change (src/qemu/qemu_driver.c). I would favor re-ordering the patches, by splitting patch 2/2 into two parts (public API, then src/remote/remote_protocol.x implementation of remote driver), then putting this patch 1/2 as the third patch. We also need a fourth patch, to tools/virsh.{pod,c} to expose the new feature through virsh. 7 files changed, 268 insertions(+), 1 deletions(-) diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in index aa320b6..25f1c9b 100644 --- a/include/libvirt/libvirt.h.in +++ b/include/libvirt/libvirt.h.in @@ -3357,6 +3357,11 @@ typedef struct _virTypedParameter virMemoryParameter; */ typedef virMemoryParameter *virMemoryParameterPtr; +typedef enum { +VIR_S3 = 1, /* Suspend-to-RAM */ +VIR_S4 = 2 /* Suspend-to-disk */ We tend to use trailing commas in enum decls (we require C99, after all), so that if we later add VIR_... = 3, we don't have to edit the VIR_S4 = 2, /* Suspend-to-disk */ line. +} virSuspendState; + This hunk should be moved alongside the half of 2/2 that deals with the public API. Also, float it up to appear earlier in the file; virMemoryParameter is in the section of deprecated names at the bottom for a reason, but virSuspendState is not deprecated, so it should appear sooner. I wonder if we should name this VIR_NODE_S3 and virNodeSuspendState, since it a different concept of 'suspend' than virDomainSuspend. +++ b/src/libvirt_private.syms @@ -844,6 +844,13 @@ nodeGetCellsFreeMemory; nodeGetFreeMemory; nodeGetInfo; nodeGetMemoryStats; +virSuspendLock; +virSuspendUnlock; +virSuspendInit; +nodeSuspendForDuration; +setNodeWakeup; +nodeSuspend; +virSuspendCleanup; Sort these lines. @@ -897,3 +905,215 @@ unsigned long long nodeGetFreeMemory(virConnectPtr conn ATTRIBUTE_UNUSED) return 0; } #endif + + +static int initialized; +virMutex virSuspendMutex; + +int virSuspendLock(void) +{ +return virMutexTryLock(virSuspendMutex); +} + +void virSuspendUnlock(void) +{ +virMutexUnlock(virSuspendMutex); +} + +/** + * virSuspendInit: + * + * Get the low power states supported by the host, such as Suspend-to-RAM (S3) + * or Suspend-to-Disk (S4), so that a request to suspend/hibernate the host + * can be handled appropriately based on this information. + * + * Returns 0 if successful, and -1 in case of error. + */ +int virSuspendInit(void) +{ + +if (virMutexInit(virSuspendMutex) 0) +return -1; + +/* Get the power management capabilities supported by the host. + * Ensure that this is done only once, by using the 'initialized' + * variable. Should this function be marked static? If it should only be called once, and 'initialized' is static, then no one outside of this file should be calling it. + */ +if (virGetPMCapabilities(hostPMFeatures) 0) { +VIR_ERROR(_(Failed to get host power management features)); +return -1; +} + +return 0; +} + + +/** + * nodeSuspendForDuration: + * @conn: pointer to the hypervisor connection + * @state: the state to which the host must be suspended to - + * VIR_HOST_PM_S3 (Suspend-to-RAM) + * or VIR_HOST_PM_S4 (Suspend-to-disk) + * @duration: the time duration in seconds, for which the host + *must be suspended + * + * Suspend the node (host machine) for the given duration of time + * in the specified state (such as S3 or S4). Resume the node + * after the time duration is complete. + * + * An RTC alarm is set appropriately to wake up the node from + * its sleep state. Then the actual node suspend is carried out + * asynchronously in another thread, after a short time delay + * so as to give enough time for this function to return status + * to its caller through the connection. + * + * Returns 0 in case the node is going to be suspended after a short + * delay, -1 if suspending the node is not supported,
[libvirt] [libvirt-glib] Release 0.0.2
From: Zeeshan Ali (Khattak) zeesha...@gnome.org --- NEWS | 20 configure.ac |3 +-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index a0cbb60..b7b11a9 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,23 @@ +0.0.2 - Nov 22, 2011 + + +- Add API to redefine an existing domain. +- Expicitely call virInitialize() to avoid connection races. +- Adjust example to latest pygobject-3.0. +- Add missing deps on libxml2-devel libtool. +- Don't introspect on RHEL6. +- Add download / mailing list links to README. +- Fix parallel build with vala bindings. +- Fix a typo in a pkg-config file. + +All contributors to this release: + +Daniel P. Berrange berra...@redhat.com +Guido Günther a...@sigxcpu.org +Marc-André Lureau marcandre.lur...@redhat.com +Nirbheek Chauhan nirbh...@gentoo.org +Zeeshan Ali (Khattak) zeesha...@gnome.org + 0.0.1 - Nov 16, 2011 diff --git a/configure.ac b/configure.ac index 464160c..56110d2 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,4 @@ - -AC_INIT(libvirt-glib, 0.0.1) +AC_INIT(libvirt-glib, 0.0.2) AC_CONFIG_SRCDIR(libvirt-glib/libvirt-glib-main.c) AC_CONFIG_AUX_DIR([build-aux]) AM_CONFIG_HEADER(config.h) -- 1.7.7.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] storage: pool definition discarded by pool-create failure
1.how to reproduce: (1)just use LVM disk,leave libvirt create vg (2)xml: pool type='logical' namepic_pool2/name source device path='/dev/sdb1'/ device path='/dev/sdb2'/ /source target path/dev/pic_pool2/path /target /pool (3)steps: a.start libvirtd,copy xml b.virsh pool-define lvm_pool.xml c.virsh pool-list --all lvm_pool exsists c.virsh pool-create lvm_pool.xml lvm_pool disappears 2.analyze: here pool-create fails because of vg has not been built before vgchange,and pool-create will delete pool-def after failure. pool-create can fail because a lot of reasons, but it doesn't mean previous pool definition should be obselete,previous definition should remain unchanged if following pool management fails. 3.fix: shall we make backend-startPool gurantee pool unchanged in condition of start fails or offer an undo function after failure? -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] storage:lvm pool creation fails because of vg not built
1.how to reproduce the reproduce steps just as http://www.redhat.com/archives/libvir-list/2011-November/msg01151.html 2.analyse: since create = define + start so pool-create can't work for the vg pre-built condition, shall we change create = define + build + start(if vg does not exist) and create=define+start(if vg exists)? Thank you for your suggestion! -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] Give correct error message when configure a wrong URI aliase.
From: Eli Qiao ta...@linux.vnet.ibm.com Signed-off-by: Eli Qiao ta...@linux.vnet.ibm.com When configure the URI aliase like this in 'libvirt.conf': uri_aliases = [ jj#j=qemu+ssh://root@127.0.0.1/system, sleet=qemu+ssh://r...@sleet.cloud.example.com/system, ] virsh -c jj#j It will show this error message: 'no connection driver available for No connection for URI jj#j' Actually ???we expect this message below??? Malformed 'uri_aliases' config entry 'jj#j=qemu+ssh://root@127.0.0.1/system', aliases may only container 'a-Z, 0-9, _, -' Give this patch to fix this error. --- src/libvirt.c |5 - 1 files changed, 0 insertions(+), 5 deletions(-) diff --git a/src/libvirt.c b/src/libvirt.c index 1518ed2..17e073e 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -1054,11 +1054,6 @@ virConnectOpenResolveURIAlias(const char *alias, char **uri) *uri = NULL; -/* Short circuit to avoid doing URI alias resolution - * when it clearly isn't an valid alias */ -if (strspn(alias, URI_ALIAS_CHARS) != strlen(alias)) -return 0; - if (!(config = virConnectConfigFile())) goto cleanup; -- 1.7.4.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] Give correct error message when configure a wrong URI aliase.
From: Eli Qiao ta...@linux.vnet.ibm.com Signed-off-by: Eli Qiao ta...@linux.vnet.ibm.com When configure the URI aliase like this in 'libvirt.conf': uri_aliases = [ jj#j=qemu+ssh://root@127.0.0.1/system, sleet=qemu+ssh://r...@sleet.cloud.example.com/system, ] virsh -c jj#j It will show this error message: 'no connection driver available for No connection for URI jj#j' Actually ???we expect this message below??? Malformed 'uri_aliases' config entry 'jj#j=qemu+ssh://root@127.0.0.1/system', aliases may only container 'a-Z, 0-9, _, -' Give this patch to fix this error. --- src/libvirt.c |5 - 1 files changed, 0 insertions(+), 5 deletions(-) diff --git a/src/libvirt.c b/src/libvirt.c index 1518ed2..17e073e 100644 --- a/src/libvirt.c +++ b/src/libvirt.c @@ -1054,11 +1054,6 @@ virConnectOpenResolveURIAlias(const char *alias, char **uri) *uri = NULL; -/* Short circuit to avoid doing URI alias resolution - * when it clearly isn't an valid alias */ -if (strspn(alias, URI_ALIAS_CHARS) != strlen(alias)) -return 0; - if (!(config = virConnectConfigFile())) goto cleanup; -- 1.7.4.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH RESEND v5] Export KVM Host Power Management capabilities
On Wed, Nov 09, 2011 at 04:38:02PM +0530, Srivatsa S. Bhat wrote: This patch exports KVM Host Power Management capabilities as XML so that higher-level systems management software can make use of these features available in the host. The script pm-is-supported (from pm-utils package) is run to discover if Suspend-to-RAM (S3) or Suspend-to-Disk (S4) is supported by the host. If either of them are supported, then a new tag power_management is introduced in the XML under the host tag. Eg: When the host supports both S3 and S4, the XML looks like this: capabilities host uuiddc699581-48a2-11cb-b8a8-9a0265a79bbe/uuid cpu archi686/arch modelcoreduo/model vendorIntel/vendor topology sockets='1' cores='2' threads='1'/ feature name='xtpr'/ feature name='tm2'/ feature name='est'/ feature name='vmx'/ feature name='pbe'/ feature name='tm'/ feature name='ht'/ feature name='ss'/ feature name='acpi'/ feature name='ds'/ /cpu power_management === New host power management features S3/ S4/ /power_management migration_features live/ uri_transports uri_transporttcp/uri_transport /uri_transports /migration_features /host . . . However in case the query to check for power management features succeeded, but the host does not support any such feature, then the XML will contain an empty power_management/ tag. In the event that the PM query itself failed, the XML will not contain any power_management tag. To use this, new APIs could be implemented in libvirt to exploit power management features such as S3/S4. This was discussed in [1] and [2]. Changelog: - This version v5: Some redundant error messages were removed and the code was streamlined. v4: http://www.redhat.com/archives/libvir-list/2011-August/msg00316.html v3: http://www.redhat.com/archives/libvir-list/2011-August/msg00282.html v2: http://www.redhat.com/archives/libvir-list/2011-August/msg00238.html v1: http://thread.gmane.org/gmane.comp.emulators.libvirt/40886 References: -- [1] http://www.redhat.com/archives/libvir-list/2011-August/msg00248.html [2] http://www.redhat.com/archives/libvir-list/2011-August/msg00302.html Signed-off-by: Srivatsa S. Bhat srivatsa.b...@linux.vnet.ibm.com [...] index 0a63a1c..eac1d02 100644 --- a/docs/schemas/capability.rng +++ b/docs/schemas/capability.rng @@ -35,6 +35,9 @@ /optional /element optional +ref name='power_management'/ + /optional + optional ref name='migration'/ /optional optional @@ -105,6 +108,21 @@ /zeroOrMore /define + define name='power_management' +element name='power_management' Seems to me you don't care about S3 and S4 order so interleave + optional +element name='S3' + empty/ +/element + /optional + optional +element name='S4' + empty/ +/element + /optional /interleave should be added, but that's minor. +/element + /define + [...] diff --git a/libvirt.spec.in b/libvirt.spec.in index c74b0ea..23487e3 100644 --- a/libvirt.spec.in +++ b/libvirt.spec.in @@ -493,6 +493,8 @@ Requires: nc Requires: gettext # Needed by virt-pki-validate script. Requires: gnutls-utils +# Needed for probing the power management features of the host. +Requires: pm-utils Okay that seems present even on RHEL-5 %if %{with_sasl} Requires: cyrus-sasl # Not technically required, but makes 'out-of-box' config diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c index 40e2976..87b60b0 100644 --- a/src/conf/capabilities.c +++ b/src/conf/capabilities.c @@ -29,6 +29,13 @@ #include util.h #include uuid.h #include cpu_conf.h +#include virterror_internal.h + + +#define VIR_FROM_THIS VIR_FROM_CAPABILITIES + +VIR_ENUM_IMPL(virHostPMCapability, VIR_HOST_PM_LAST, + S3, S4) /** * virCapabilitiesNew: @@ -201,7 +208,6 @@ virCapabilitiesAddHostFeature(virCapsPtr caps, return 0; } - /** * virCapabilitiesAddHostMigrateTransport: * @caps: capabilities to extend @@ -687,6 +693,25 @@ virCapabilitiesFormatXML(virCapsPtr caps) virBufferAddLit(xml, /cpu\n); +if (caps-host.powerMgmt_valid) { +/* The PM query was successful. */ +if (caps-host.powerMgmt) { +/* The host supports some PM features. */ +unsigned int pm = caps-host.powerMgmt; +virBufferAddLit(xml, power_management\n); +while (pm) { +int bit = ffs(pm) - 1; +virBufferAsprintf(xml, %s/\n, +virHostPMCapabilityTypeToString(bit)); +pm = ~(1U bit); +} +
Re: [libvirt] storage: pool definition discarded by pool-create failure
On 2011年11月22日 10:38, lvroyce wrote: 1.how to reproduce: (1)just use LVM disk,leave libvirt create vg (2)xml: pool type='logical' namepic_pool2/name source device path='/dev/sdb1'/ device path='/dev/sdb2'/ /source target path/dev/pic_pool2/path /target /pool (3)steps: a.start libvirtd,copy xml b.virsh pool-define lvm_pool.xml c.virsh pool-list --all lvm_pool exsists c.virsh pool-create lvm_pool.xml lvm_pool disappears 2.analyze: here pool-create fails because of vg has not been built before vgchange,and pool-create will delete pool-def after failure. pool-create can fail because a lot of reasons, but it doesn't mean previous pool definition should be obselete,previous definition should remain unchanged if following pool management fails. Actually there is similiar problem for domain create too. # virsh define test.xml # virsh create test.xml It's caused domainCreateXML will free the domain config regardless of if the domain is persistent or not. But the persistent XML file is not removed, once libvirtd is restarted, you will see the domain again. The problem here is it should check if the domain conf is persistent before free() it, or prohibit creating the domain if it's already defined. Not sure which way is better, but considering we allow to re-define a domain config, may be the first way is right way to go? Regards, Osier -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] storage: pool definition discarded by pool-create failure
On 2011年11月22日 10:38, lvroyce wrote: 1.how to reproduce: (1)just use LVM disk,leave libvirt create vg (2)xml: pool type='logical' namepic_pool2/name source device path='/dev/sdb1'/ device path='/dev/sdb2'/ /source target path/dev/pic_pool2/path /target /pool (3)steps: a.start libvirtd,copy xml b.virsh pool-define lvm_pool.xml c.virsh pool-list --all lvm_pool exsists c.virsh pool-create lvm_pool.xml lvm_pool disappears 2.analyze: here pool-create fails because of vg has not been built before vgchange,and pool-create will delete pool-def after failure. pool-create can fail because a lot of reasons, but it doesn't mean previous pool definition should be obselete,previous definition should remain unchanged if following pool management fails. Actually there is similiar problem for domain create too. # virsh define test.xml # virsh create test.xml It's caused domainCreateXML will free the domain config regardless of if the domain is persistent or not. But the persistent XML file is not removed, once libvirtd is restarted, you will see the domain again. The problem here is it should check if the domain conf is persistent before free() it, or prohibit creating the domain if it's already defined. Not sure which way is better, but considering we allow to re-define a domain config, may be the first way is right way to go? Regards, Osier -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] storage:lvm pool creation fails because of vg not built
On 2011年11月22日 10:45, lvroyce wrote: 1.how to reproduce the reproduce steps just as http://www.redhat.com/archives/libvir-list/2011-November/msg01151.html 2.analyse: since create = define + start so pool-create can't work for the vg pre-built condition, shall we change create = define + build + start(if vg does not exist) and create=define+start(if vg exists)? Thank you for your suggestion! Per it already combines start + refresh together, personally I think it's fine to combine build together too. But it needs flag too keep backwards compatibility. Regards, Osier -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v3 0/2] API to invoke S3/S4 on a host and also resume from within libvirt
On Mon, Nov 21, 2011 at 05:26:55PM -0700, Eric Blake wrote: On 11/09/2011 05:05 AM, Srivatsa S. Bhat wrote: (This patch is positioned to go in after the patch that exports the host power management capabilities as XML, posted in [4]) I'm now reviewing that patch along with this series; if we need another revision, it may be easiest to merge the three patches into a single series and title it v6, so that they are together in one thread. Ah, too bad, I already reviewed and pushed, that could go standalone even if it is of limited use by itself, Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ dan...@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/ -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list