Re: [libvirt] [test-API][PATCH 2/3] "clean" keyword update in libvirt-test-api, mapper, proxy part
On 11/10/2011 11:25 AM, Guannan Sun wrote: NACK - Original Message - From: "Guannan Ren" To: libvir-list@redhat.com Sent: Wednesday, November 9, 2011 12:38:38 PM Subject: [libvirt] [test-API][PATCH 2/3] "clean" keyword update in libvirt-test-api, mapper, proxy part --- libvirt-test-api.py |7 +++ mapper.py | 24 +++- proxy.py| 13 + 3 files changed, 35 insertions(+), 9 deletions(-) diff --git a/libvirt-test-api.py b/libvirt-test-api.py index 8a4bacd..171e13c 100644 --- a/libvirt-test-api.py +++ b/libvirt-test-api.py @@ -100,13 +100,20 @@ class LibvirtTestAPI(object): # extract the string of combination of # language, package, testname of a testcase. all_testcases_names = [] +prev_casename = '' for activity in activities_list: for testcase in activity: testcases_names = testcase.keys() if 'sleep' in testcases_names: testcases_names.remove('sleep') +if not cmp('clean', testcases_names[0]): +all_testcases_names += [prev_casename + ":_clean"] +continue + +prev_casename = testcases_names[0] all_testcases_names += testcases_names + unique_testcases_names = list(set(all_testcases_names)) # call and initilize proxy component to diff --git a/mapper.py b/mapper.py index 4f41230..affc510 100644 --- a/mapper.py +++ b/mapper.py @@ -24,20 +24,34 @@ class Mapper(object): def __init__(self, testcases_list): self.testcases_list = copy.deepcopy(testcases_list) -def get_package_tripped(self): +def package_casename_func_map(self): ^^^ The change of function name will cause problem when options cleanup enabled in test conf files, function name should also be udpated in env_clear.py After update function name in env_clear.py, another problem came out which the whole case will be rerun in cleanup process. So, update needed. Yes, the code for keyword "cleanup" is still not updated after changing the way of referencing test function. I will send patches later. Thanks. -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] nwfilter - limit VM traffic to specific mac address
On 09.11.11 10:49, Stefan Berger wrote: > On 11/09/2011 09:38 AM, Shahar Havivi wrote: > >On 09.11.11 09:20, Stefan Berger wrote: > >>On 11/09/2011 07:44 AM, Shahar Havivi wrote: > >>>On 09.11.11 06:44, Stefan Berger wrote: > On 11/09/2011 04:01 AM, Shahar Havivi wrote: > >On 08.11.11 16:34, Stefan Berger wrote: > >>On 11/07/2011 04:25 AM, Shahar Havivi wrote: > >>>Hi, > >>> > >>>I want to limit VM traffic to a specific MAC address, ie VMs cannot > >>>traffic each other other then a specific gateway. > >>> > >>>I am using custom nwfilter name: isolatedprivatevlan-vdsm.xml > >>>located in /etc/libvirt/nwfilter/: > >>> > >>> > >>> > >>> > >>> > >>> > >>> > >>> > >>Try this one -- it works in 'my' subnet: > >> > >> > >> > >> > >> > >> > >> > >Thanks, > >Now it is blocking the traffic but I can't get traffic to the gateway as > >well... > That's odd. Can you ping the gateway from the VM? Is it typically > ping-able? Are you sure you specified the correct MAC addresses -- > check with 'arp -n' on a host in the same subnet and see what it > shows for the gateway (ping it if you don't see an entry). > > Stefan > >>>It's working only when I remove the line > >>> > >>>from the filter... > >>While you ping the gateway, can you re-add the above line to the filter? > >> > >>Stefan > >its working, even when stopping the ping and re-pinging the gateway, > >but it stop working after I stop and started the VM. > > > How does the VM get its IP address, static or DHCP ? If DHCP, could > you try a static IP address? > > In case it doesn't work, what does 'ebtables -t nat -L' show and > which IP address is assigned to the VM's interface? > >Stefan static ip, the ebtables output show ip 0.0.0.0 for the VM mac address: Bridge chain: I-vnet0-rarp, entries: 2, policy: ACCEPT -p 0x8035 -s 0:1a:4a:16:1:52 -d Broadcast --arp-op Request_Reverse --arp-ip-src 0.0.0.0 --arp-ip-dst 0.0.0.0 --arp-mac-src 0:1a:4a:16:1:52 --arp-mac-dst 0:1a:4a:16:1:52 -j ACCEPT -j DROP Bridge chain: O-vnet0-rarp, entries: 2, policy: ACCEPT -p 0x8035 -d Broadcast --arp-op Request_Reverse --arp-ip-src 0.0.0.0 --arp-ip-dst 0.0.0.0 --arp-mac-src 0:1a:4a:16:1:52 --arp-mac-dst 0:1a:4a:16:1:52 -j ACCEPT -j DROP How can I set the IP in the case? > -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] nwfilter - limit VM traffic to specific mac address
On 10.11.11 11:30, Shahar Havivi wrote: > On 09.11.11 10:49, Stefan Berger wrote: > > On 11/09/2011 09:38 AM, Shahar Havivi wrote: > > >On 09.11.11 09:20, Stefan Berger wrote: > > >>On 11/09/2011 07:44 AM, Shahar Havivi wrote: > > >>>On 09.11.11 06:44, Stefan Berger wrote: > > On 11/09/2011 04:01 AM, Shahar Havivi wrote: > > >On 08.11.11 16:34, Stefan Berger wrote: > > >>On 11/07/2011 04:25 AM, Shahar Havivi wrote: > > >>>Hi, > > >>> > > >>>I want to limit VM traffic to a specific MAC address, ie VMs cannot > > >>>traffic each other other then a specific gateway. > > >>> > > >>>I am using custom nwfilter name: isolatedprivatevlan-vdsm.xml > > >>>located in /etc/libvirt/nwfilter/: > > >>> > > >>> > > >>> > > >>> > > >>> > > >>> > > >>> > > >>> > > >>Try this one -- it works in 'my' subnet: > > >> > > >> > > >> > > >> > > >> > > >> > > >> > > >Thanks, > > >Now it is blocking the traffic but I can't get traffic to the gateway > > >as > > >well... > > That's odd. Can you ping the gateway from the VM? Is it typically > > ping-able? Are you sure you specified the correct MAC addresses -- > > check with 'arp -n' on a host in the same subnet and see what it > > shows for the gateway (ping it if you don't see an entry). > > > > Stefan > > >>>It's working only when I remove the line > > >>> > > >>>from the filter... > > >>While you ping the gateway, can you re-add the above line to the filter? > > >> > > >>Stefan > > >its working, even when stopping the ping and re-pinging the gateway, > > >but it stop working after I stop and started the VM. > > > > > How does the VM get its IP address, static or DHCP ? If DHCP, could > > you try a static IP address? > > > > In case it doesn't work, what does 'ebtables -t nat -L' show and > > which IP address is assigned to the VM's interface? > > > >Stefan > static ip, the ebtables output show ip 0.0.0.0 for the VM mac address: > > Bridge chain: I-vnet0-rarp, entries: 2, policy: ACCEPT > -p 0x8035 -s 0:1a:4a:16:1:52 -d Broadcast --arp-op Request_Reverse > --arp-ip-src 0.0.0.0 --arp-ip-dst 0.0.0.0 --arp-mac-src 0:1a:4a:16:1:52 > --arp-mac-dst 0:1a:4a:16:1:52 -j ACCEPT > -j DROP > > Bridge chain: O-vnet0-rarp, entries: 2, policy: ACCEPT > -p 0x8035 -d Broadcast --arp-op Request_Reverse --arp-ip-src 0.0.0.0 > --arp-ip-dst 0.0.0.0 --arp-mac-src 0:1a:4a:16:1:52 --arp-mac-dst > 0:1a:4a:16:1:52 -j ACCEPT > -j DROP > > > How can I set the IP in the case? Ok, its working when I set the IP in the filter: I guess its the only solution...? > > > > -- > 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] [PATCH] fix crash when starting network
tested-by: Wen Ruo Lv tested 1.net-start cmd with bridge mac specified (failed) 2.attach-device cmd with a hot plug nic(ok) My network is as below: default 361441af-e1f0-472d-a503-dfcbbefa03fb It fails at brSetInterfaceMac-->return ioctl(ctl->fd, SIOCSIFHWADDR, &ifr) but SIOCGIFHWADDR succeed. error msg is: cannot create dummy tap device 'virbr0-nic' to set mac address on bridge 'virbr0':no such device -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] nwfilter - limit VM traffic to specific mac address
On 11/10/2011 05:21 AM, Shahar Havivi wrote: On 10.11.11 11:30, Shahar Havivi wrote: On 09.11.11 10:49, Stefan Berger wrote: On 11/09/2011 09:38 AM, Shahar Havivi wrote: On 09.11.11 09:20, Stefan Berger wrote: On 11/09/2011 07:44 AM, Shahar Havivi wrote: On 09.11.11 06:44, Stefan Berger wrote: On 11/09/2011 04:01 AM, Shahar Havivi wrote: On 08.11.11 16:34, Stefan Berger wrote: On 11/07/2011 04:25 AM, Shahar Havivi wrote: Hi, I want to limit VM traffic to a specific MAC address, ie VMs cannot traffic each other other then a specific gateway. I am using custom nwfilter name: isolatedprivatevlan-vdsm.xml located in /etc/libvirt/nwfilter/: Try this one -- it works in 'my' subnet: Thanks, Now it is blocking the traffic but I can't get traffic to the gateway as well... That's odd. Can you ping the gateway from the VM? Is it typically ping-able? Are you sure you specified the correct MAC addresses -- check with 'arp -n' on a host in the same subnet and see what it shows for the gateway (ping it if you don't see an entry). Stefan It's working only when I remove the line >from the filter... While you ping the gateway, can you re-add the above line to the filter? Stefan its working, even when stopping the ping and re-pinging the gateway, but it stop working after I stop and started the VM. How does the VM get its IP address, static or DHCP ? If DHCP, could you try a static IP address? In case it doesn't work, what does 'ebtables -t nat -L' show and which IP address is assigned to the VM's interface? Stefan static ip, the ebtables output show ip 0.0.0.0 for the VM mac address: Bridge chain: I-vnet0-rarp, entries: 2, policy: ACCEPT -p 0x8035 -s 0:1a:4a:16:1:52 -d Broadcast --arp-op Request_Reverse --arp-ip-src 0.0.0.0 --arp-ip-dst 0.0.0.0 --arp-mac-src 0:1a:4a:16:1:52 --arp-mac-dst 0:1a:4a:16:1:52 -j ACCEPT -j DROP Bridge chain: O-vnet0-rarp, entries: 2, policy: ACCEPT -p 0x8035 -d Broadcast --arp-op Request_Reverse --arp-ip-src 0.0.0.0 --arp-ip-dst 0.0.0.0 --arp-mac-src 0:1a:4a:16:1:52 --arp-mac-dst 0:1a:4a:16:1:52 -j ACCEPT -j DROP How can I set the IP in the case? Ok, its working when I set the IP in the filter: I guess its the only solution...? The IP address in the parameter XML node has to match the one assigned to the interface inside the VM. If they don't match nothing works. If you leave out the line '' then this will start libvirt's IP address learning/detection that will lock your VM into the first IP address it detects that the VM is using on a particular interface. This should also work. Stefan -- 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] nwfilter - limit VM traffic to specific mac address
On 10.11.11 06:25, Stefan Berger wrote: > On 11/10/2011 05:21 AM, Shahar Havivi wrote: > >On 10.11.11 11:30, Shahar Havivi wrote: > >>On 09.11.11 10:49, Stefan Berger wrote: > >>>On 11/09/2011 09:38 AM, Shahar Havivi wrote: > On 09.11.11 09:20, Stefan Berger wrote: > >On 11/09/2011 07:44 AM, Shahar Havivi wrote: > >>On 09.11.11 06:44, Stefan Berger wrote: > >>>On 11/09/2011 04:01 AM, Shahar Havivi wrote: > On 08.11.11 16:34, Stefan Berger wrote: > >On 11/07/2011 04:25 AM, Shahar Havivi wrote: > >>Hi, > >> > >>I want to limit VM traffic to a specific MAC address, ie VMs cannot > >>traffic each other other then a specific gateway. > >> > >>I am using custom nwfilter name: isolatedprivatevlan-vdsm.xml > >>located in /etc/libvirt/nwfilter/: > >> > >> > >> > >> > >> > >> > >> > >> > >Try this one -- it works in 'my' subnet: > > > > > > > > > > > > > > > Thanks, > Now it is blocking the traffic but I can't get traffic to the gateway > as > well... > >>>That's odd. Can you ping the gateway from the VM? Is it typically > >>>ping-able? Are you sure you specified the correct MAC addresses -- > >>>check with 'arp -n' on a host in the same subnet and see what it > >>>shows for the gateway (ping it if you don't see an entry). > >>> > >>> Stefan > >>It's working only when I remove the line > >> > >>from the filter... > >While you ping the gateway, can you re-add the above line to the filter? > > > >Stefan > its working, even when stopping the ping and re-pinging the gateway, > but it stop working after I stop and started the VM. > > >>>How does the VM get its IP address, static or DHCP ? If DHCP, could > >>>you try a static IP address? > >>> > >>>In case it doesn't work, what does 'ebtables -t nat -L' show and > >>>which IP address is assigned to the VM's interface? > >>> > >>>Stefan > >>static ip, the ebtables output show ip 0.0.0.0 for the VM mac address: > >> > >>Bridge chain: I-vnet0-rarp, entries: 2, policy: ACCEPT > >>-p 0x8035 -s 0:1a:4a:16:1:52 -d Broadcast --arp-op Request_Reverse > >>--arp-ip-src 0.0.0.0 --arp-ip-dst 0.0.0.0 --arp-mac-src 0:1a:4a:16:1:52 > >>--arp-mac-dst 0:1a:4a:16:1:52 -j ACCEPT > >>-j DROP > >> > >>Bridge chain: O-vnet0-rarp, entries: 2, policy: ACCEPT > >>-p 0x8035 -d Broadcast --arp-op Request_Reverse --arp-ip-src 0.0.0.0 > >>--arp-ip-dst 0.0.0.0 --arp-mac-src 0:1a:4a:16:1:52 --arp-mac-dst > >>0:1a:4a:16:1:52 -j ACCEPT > >>-j DROP > >> > >> > >>How can I set the IP in the case? > >Ok, > >its working when I set the IP in the filter: > > > > > > > > > >I guess its the only solution...? > The IP address in the parameter XML node has to match the one > assigned to the interface inside the VM. If they don't match nothing > works. If you leave out the line '' then this > will start libvirt's IP address learning/detection that will lock > your VM into the first IP address it detects that the VM is using on > a particular interface. This should also work. > >Stefan Thank you Stefan > >>-- > >>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
[libvirt] [PATCH 3/4] Allow creation of plain macvlan devices
From: "Daniel P. Berrange" Update virNetDevMacVLanCreateWithVPortProfile to allow creation of plain macvlan devices, as well as macvtap devices. The former is useful for LXC containers * src/qemu/qemu_command.c: Explicitly request a macvtap device * src/util/virnetdevmacvlan.c, src/util/virnetdevmacvlan.h: Add new flag to allow switching between macvlan and macvtap creation --- src/qemu/qemu_command.c |2 +- src/util/virnetdevmacvlan.c | 41 - src/util/virnetdevmacvlan.h |5 +++-- 3 files changed, 32 insertions(+), 16 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 6df1f83..2f01436 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -154,7 +154,7 @@ qemuPhysIfaceConnect(virDomainDefPtr def, net->ifname, net->mac, virDomainNetGetActualDirectDev(net), virDomainNetGetActualDirectMode(net), -vnet_hdr, def->uuid, +true, vnet_hdr, def->uuid, virDomainNetGetActualDirectVirtPortProfile(net), &res_ifname, vmop, driver->stateDir, diff --git a/src/util/virnetdevmacvlan.c b/src/util/virnetdevmacvlan.c index fe2f383..98b0f9a 100644 --- a/src/util/virnetdevmacvlan.c +++ b/src/util/virnetdevmacvlan.c @@ -72,11 +72,14 @@ VIR_ENUM_IMPL(virNetDevMacVLanMode, VIR_NETDEV_MACVLAN_MODE_LAST, # define MACVTAP_NAME_PREFIX "macvtap" # define MACVTAP_NAME_PATTERN "macvtap%d" +# define MACVLAN_NAME_PREFIX "macvlan" +# define MACVLAN_NAME_PATTERN "macvlan%d" + /** * virNetDevMacVLanCreate: * * @ifname: The name the interface is supposed to have; optional parameter - * @type: The type of device, i.e., "macvtap" + * @type: The type of device, i.e., "macvtap", "macvlan" * @macaddress: The MAC address of the device * @srcdev: The name of the 'link' device * @macvlan_mode: The macvlan mode to use @@ -458,14 +461,14 @@ static const uint32_t modeMap[VIR_NETDEV_MACVLAN_MODE_LAST] = { * interface will be stored into if everything succeeded. It is up * to the caller to free the string. * - * Returns file descriptor of the tap device in case of success, - * negative value otherwise with error reported. - * + * Returns file descriptor of the tap device in case of success with @withTap, + * otherwise returns 0; returns -1 on error. */ int virNetDevMacVLanCreateWithVPortProfile(const char *tgifname, const unsigned char *macaddress, const char *linkdev, enum virNetDevMacVLanMode mode, + bool withTap, int vnet_hdr, const unsigned char *vmuuid, virNetDevVPortProfilePtr virtPortProfile, @@ -474,7 +477,9 @@ int virNetDevMacVLanCreateWithVPortProfile(const char *tgifname, char *stateDir, virNetDevBandwidthPtr bandwidth) { -const char *type = "macvtap"; +const char *type = withTap ? "macvtap" : "macvlan"; +const char *prefix = withTap ? MACVTAP_NAME_PREFIX : MACVLAN_NAME_PREFIX; +const char *pattern = withTap ? MACVTAP_NAME_PATTERN : MACVLAN_NAME_PATTERN; int c, rc; char ifname[IFNAMSIZ]; int retries, do_retry = 0; @@ -505,8 +510,7 @@ int virNetDevMacVLanCreateWithVPortProfile(const char *tgifname, return -1; if (ret) { -if (STRPREFIX(tgifname, - MACVTAP_NAME_PREFIX)) { +if (STRPREFIX(tgifname, prefix)) { goto create_name; } virReportSystemError(EEXIST, @@ -522,7 +526,7 @@ int virNetDevMacVLanCreateWithVPortProfile(const char *tgifname, create_name: retries = 5; for (c = 0; c < 8192; c++) { -snprintf(ifname, sizeof(ifname), MACVTAP_NAME_PATTERN, c); +snprintf(ifname, sizeof(ifname), pattern, c); if ((ret = virNetDevExists(ifname)) < 0) return -1; if (!ret) { @@ -553,15 +557,26 @@ create_name: goto disassociate_exit; } -rc = virNetDevMacVLanTapOpen(cr_ifname, 10); -if (rc >= 0) { +if (withTap) { +if ((rc = virNetDevMacVLanTapOpen(cr_ifname, 10)) < 0) +goto disassociate_exit; + if (virNetDevMacVLanTapSetup(rc, vnet_hdr) < 0) { VIR_FORCE_CLOSE(rc); /* sets rc to -1 */ goto disassociate_exit; } -*res_ifname = strdup(cr_ifname); -} else -goto disassociate_exit; +if (!(*res_ifname = strdup(cr_ifname))) { +VIR_FORCE_CLOSE(rc); /* sets rc to -1 */ +virReportOOMError(); +goto disassociate_exit; +} +} else { +if (!(*res_ifname = strdup(cr_ifname)))
[libvirt] [PATCH 4/4] Add support for interfaces with type=direct to LXC
From: "Daniel P. Berrange" Support creation of macvlan devices for LXC containers. Do not allow setting of network filters, bandwidth controls or vport profiles due to the complication that there is no host side visible device to work with. * src/lxc/lxc_driver.c: Support type=direct interfaces --- src/lxc/lxc_driver.c | 106 +- 1 files changed, 105 insertions(+), 1 deletions(-) diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 4f6807b..09752a3 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -1230,6 +1230,102 @@ cleanup: return ret; } + +static int lxcSetupInterfaceDirect(virConnectPtr conn, + virDomainDefPtr def, + virDomainNetDefPtr net, + unsigned int *nveths, + char ***veths) +{ +int ret = 0; +char *res_ifname = NULL; +lxc_driver_t *driver = conn->privateData; +virNetDevBandwidthPtr bw; +virNetDevVPortProfilePtr prof; + +/* XXX how todo filtering ? + * Since the 'net-ifname' is about to be moved to a different + * namespace & renamed, there will be no host side visible + * interface for the container to attach rules to + */ +if (net->filter) { +lxcError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Unable to set network filters on direct interfaces")); +return -1; +} + +/* XXX how todo bandwidth controls ? + * Since the 'net-ifname' is about to be moved to a different + * namespace & renamed, there will be no host side visible + * interface for the container to attach rules to + */ +bw = virDomainNetGetActualBandwidth(net); +if (bw) { +lxcError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Unable to set network bandwidth on direct interfaces")); +return -1; +} + +/* XXX how todo port profiles ? + * Although we can do the association during container + * startup, at shutdown we are unable to disassociate + * because the macvlan device was moved to the container + * and automagically dies when the container dies. So + * we have no dev to perform disassociation with. + */ +prof = virDomainNetGetActualDirectVirtPortProfile(net); +if (prof) { +lxcError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Unable to set port profile on direct interfaces")); +return -1; +} + +if (VIR_REALLOC_N(*veths, (*nveths)+1) < 0) { +virReportOOMError(); +return -1; +} +(*veths)[(*nveths)] = NULL; + +if (virNetDevMacVLanCreateWithVPortProfile( +net->ifname, net->mac, +virDomainNetGetActualDirectDev(net), +virDomainNetGetActualDirectMode(net), +false, false, def->uuid, +virDomainNetGetActualDirectVirtPortProfile(net), +&res_ifname, +VIR_NETDEV_VPORT_PROFILE_OP_CREATE, +driver->stateDir, +virDomainNetGetActualBandwidth(net)) < 0) +goto cleanup; + +(*veths)[(*nveths)] = res_ifname; +(*nveths)++; + +#if 0 +if (rc >= 0) { +if ((net->filter) && (net->ifname)) { +err = virDomainConfNWFilterInstantiate(conn, net); +if (err) { +VIR_FORCE_CLOSE(rc); +ignore_value(virNetDevMacVLanDeleteWithVPortProfile( + net->ifname, net->mac, + virDomainNetGetActualDirectDev(net), + virDomainNetGetActualDirectMode(net), + virDomainNetGetActualDirectVirtPortProfile(net), + driver->stateDir)); +VIR_FREE(net->ifname); +} +} +} +#endif + +ret = 0; + +cleanup: +return ret; +} + + /** * lxcSetupInterfaces: * @conn: pointer to connection @@ -1299,13 +1395,21 @@ static int lxcSetupInterfaces(virConnectPtr conn, goto cleanup; } break; +case VIR_DOMAIN_NET_TYPE_DIRECT: +if (lxcSetupInterfaceDirect(conn, +def, +def->nets[i], +nveths, +veths) < 0) +goto cleanup; +break; + case VIR_DOMAIN_NET_TYPE_USER: case VIR_DOMAIN_NET_TYPE_ETHERNET: case VIR_DOMAIN_NET_TYPE_SERVER: case VIR_DOMAIN_NET_TYPE_CLIENT: case VIR_DOMAIN_NET_TYPE_MCAST: case VIR_DOMAIN_NET_TYPE_INTERNAL: -case VIR_DOMAIN_NET_TYPE_DIRECT: case VIR_DOMAIN_NET_TYPE_LAST: lxcError(VIR_ERR_INTERNAL_ERROR, _("Unsupported network type %s"), -- 1.7.6.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mai
[libvirt] [PATCH] Add libvirt confdir to files section in mingw32 spec
From: "Daniel P. Berrange" Pushed under the trivial rule - this fix pulled back from Fedora * mingw32-libvirt.spec.in: Ensure we own the confdir --- mingw32-libvirt.spec.in |1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/mingw32-libvirt.spec.in b/mingw32-libvirt.spec.in index c2690f3..89d1d7f 100644 --- a/mingw32-libvirt.spec.in +++ b/mingw32-libvirt.spec.in @@ -126,6 +126,7 @@ rm -rf $RPM_BUILD_ROOT %files %defattr(-,root,root) +%dir %{_mingw32_sysconfdir}/libvirt/ %config(noreplace) %{_mingw32_sysconfdir}/libvirt/libvirt.conf %{_mingw32_bindir}/libvirt-0.dll -- 1.7.6.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 2/4] Refactor LXC network setup to allow future enhancements
From: "Daniel P. Berrange" The current lxcSetupInterfaces() method directly performs setup of the bridge devices. Since it will shortly need to also create macvlan devices, move the bridge related code into a separate method * src/lxc/lxc_driver.c: Split lxcSetupInterfaces() to create a new lxcSetupInterfaceBridge() --- src/lxc/lxc_driver.c | 167 + 1 files changed, 99 insertions(+), 68 deletions(-) diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index ccd8bad..4f6807b 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -1175,6 +1175,61 @@ static void lxcVmCleanup(lxc_driver_t *driver, } } + +static int lxcSetupInterfaceBridged(virConnectPtr conn, +virDomainNetDefPtr net, +const char *brname, +unsigned int *nveths, +char ***veths) +{ +int ret = -1; +char *parentVeth; +char *containerVeth = NULL; + +VIR_DEBUG("calling vethCreate()"); +parentVeth = net->ifname; +if (virNetDevVethCreate(&parentVeth, &containerVeth) < 0) +goto cleanup; +VIR_DEBUG("parentVeth: %s, containerVeth: %s", parentVeth, containerVeth); + +if (net->ifname == NULL) +net->ifname = parentVeth; + +if (VIR_REALLOC_N(*veths, (*nveths)+1) < 0) { +virReportOOMError(); +VIR_FREE(containerVeth); +goto cleanup; +} +(*veths)[(*nveths)] = containerVeth; +(*nveths)++; + +if (virNetDevSetMAC(containerVeth, net->mac) < 0) +goto cleanup; + +if (virNetDevBridgeAddPort(brname, parentVeth) < 0) +goto cleanup; + +if (virNetDevSetOnline(parentVeth, true) < 0) +goto cleanup; + +if (virNetDevBandwidthSet(net->ifname, + virDomainNetGetActualBandwidth(net)) < 0) { +lxcError(VIR_ERR_INTERNAL_ERROR, + _("cannot set bandwidth limits on %s"), + net->ifname); +goto cleanup; +} + +if (net->filter && +virDomainConfNWFilterInstantiate(conn, net) < 0) +goto cleanup; + +ret = 0; + +cleanup: +return ret; +} + /** * lxcSetupInterfaces: * @conn: pointer to connection @@ -1193,39 +1248,56 @@ static int lxcSetupInterfaces(virConnectPtr conn, unsigned int *nveths, char ***veths) { -int rc = -1, i; -char *bridge = NULL; +int ret = -1; +size_t i; for (i = 0 ; i < def->nnets ; i++) { -char *parentVeth; -char *containerVeth = NULL; - /* If appropriate, grab a physical device from the configured * network's pool of devices, or resolve bridge device name * to the one defined in the network definition. */ if (networkAllocateActualDevice(def->nets[i]) < 0) -goto error_exit; +goto cleanup; switch (virDomainNetGetActualType(def->nets[i])) { -case VIR_DOMAIN_NET_TYPE_NETWORK: -{ +case VIR_DOMAIN_NET_TYPE_NETWORK: { virNetworkPtr network; +char *brname = NULL; -network = virNetworkLookupByName(conn, - def->nets[i]->data.network.name); -if (!network) { -goto error_exit; -} - -bridge = virNetworkGetBridgeName(network); +if (!(network = virNetworkLookupByName(conn, + def->nets[i]->data.network.name))) +goto cleanup; +brname = virNetworkGetBridgeName(network); virNetworkFree(network); +if (!brname) +goto cleanup; + +if (lxcSetupInterfaceBridged(conn, + def->nets[i], + brname, + nveths, + veths) < 0) { +VIR_FREE(brname); +goto cleanup; +} +VIR_FREE(brname); break; } -case VIR_DOMAIN_NET_TYPE_BRIDGE: -bridge = virDomainNetGetActualBridgeName(def->nets[i]); -break; +case VIR_DOMAIN_NET_TYPE_BRIDGE: { +const char *brname = virDomainNetGetActualBridgeName(def->nets[i]); +if (!brname) { +lxcError(VIR_ERR_INTERNAL_ERROR, "%s", + _("No bridge name specified")); +goto cleanup; +} +if (lxcSetupInterfaceBridged(conn, + def->nets[i], + brname, + nveths, + veths) < 0) +goto cleanup; +} break; cas
[libvirt] [PATCH 1/4] Add missing 'const' annotations for internal domain conf helpers
From: "Daniel P. Berrange" The virDomainNetGetActualBridgeName and virDomainNetGetActualDirectDev methods both return strings that point to data in the virDomainDefPtr struct, and should therefore not be freed. The return values should thus be 'const char *' not 'char *'. * src/conf/domain_conf.c, src/conf/domain_conf.h: Mark const * src/network/bridge_driver.c: Update to use a const char * --- src/conf/domain_conf.c |4 ++-- src/conf/domain_conf.h |4 ++-- src/network/bridge_driver.c | 12 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 9528697..5a83dec 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -13046,7 +13046,7 @@ virDomainNetGetActualType(virDomainNetDefPtr iface) return iface->data.network.actual->type; } -char * +const char * virDomainNetGetActualBridgeName(virDomainNetDefPtr iface) { if (iface->type == VIR_DOMAIN_NET_TYPE_BRIDGE) @@ -13058,7 +13058,7 @@ virDomainNetGetActualBridgeName(virDomainNetDefPtr iface) return iface->data.network.actual->data.bridge.brname; } -char * +const char * virDomainNetGetActualDirectDev(virDomainNetDefPtr iface) { if (iface->type == VIR_DOMAIN_NET_TYPE_DIRECT) diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 9528199..4e86d30 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1794,8 +1794,8 @@ int virDomainGraphicsListenSetNetwork(virDomainGraphicsDefPtr def, ATTRIBUTE_NONNULL(1); int virDomainNetGetActualType(virDomainNetDefPtr iface); -char *virDomainNetGetActualBridgeName(virDomainNetDefPtr iface); -char *virDomainNetGetActualDirectDev(virDomainNetDefPtr iface); +const char *virDomainNetGetActualBridgeName(virDomainNetDefPtr iface); +const char *virDomainNetGetActualDirectDev(virDomainNetDefPtr iface); int virDomainNetGetActualDirectMode(virDomainNetDefPtr iface); virNetDevVPortProfilePtr virDomainNetGetActualDirectVirtPortProfile(virDomainNetDefPtr iface); diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 5dfc294..623e4b3 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -2898,7 +2898,7 @@ networkNotifyActualDevice(virDomainNetDefPtr iface) struct network_driver *driver = driverState; virNetworkObjPtr network; virNetworkDefPtr netdef; -char *actualDev; +const char *actualDev; int ret = -1; if (iface->type != VIR_DOMAIN_NET_TYPE_NETWORK) @@ -2924,8 +2924,8 @@ networkNotifyActualDevice(virDomainNetDefPtr iface) if (!actualDev) { networkReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("the interface uses a direct mode, but has no source dev")); -goto cleanup; -} +goto cleanup; +} netdef = network->def; if (netdef->nForwardIfs == 0) { @@ -2998,7 +2998,7 @@ networkReleaseActualDevice(virDomainNetDefPtr iface) struct network_driver *driver = driverState; virNetworkObjPtr network = NULL; virNetworkDefPtr netdef; -char *actualDev; +const char *actualDev; int ret = -1; if (iface->type != VIR_DOMAIN_NET_TYPE_NETWORK) @@ -3025,8 +3025,8 @@ networkReleaseActualDevice(virDomainNetDefPtr iface) if (!actualDev) { networkReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("the interface uses a direct mode, but has no source dev")); -goto cleanup; -} +goto cleanup; +} netdef = network->def; if (netdef->nForwardIfs == 0) { -- 1.7.6.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 0/4] Support macvlan devices for LXC containers
This series does the bare minimum required to support the network inteface type=direct for LXC containers, using macvlan devices as the implementation. There is a slight complication though... For bridged container NICs we create a veth pair of devices. One of the devices lives host side, and is enslaved in a bridge. The other veth device gets moved to the container namespace to form the eth0. So we both both a host & container side device visible. For direct container NICS we create a macvlan device, which is moved to the container namespace. There is no host side interface that is dedicated for the container - only the general ethernet device the macvlan is bound to. Since there is no host side interface for the container we are unable to create network filter rules, or network bandwidth controls. In addition while we could perform the 8021.Qb{gh} association during container startup, before moving the macvlan device to the container namespace, we can't perform any disassociation on container shutdown. By the time we see the container has shutdown, the macvlan device has already been killed off. The inability to setup iptables/tc rules against devices that are only visible in the container namespace is arguably a flaw in the Linux kernel's namespace code support for iptables/tc. There ought to be a syntax for iptables/tc to write rules which affect NICs in other namespaces -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH] Disable numactl on ARM architectures too
From: "Daniel P. Berrange" Pushed under trivial rule - a backport from the Fedora spec * libvirt.spec.in: Disable numactl on ARM --- libvirt.spec.in |4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libvirt.spec.in b/libvirt.spec.in index 10280f0..d4e3e17 100644 --- a/libvirt.spec.in +++ b/libvirt.spec.in @@ -92,8 +92,8 @@ %define with_libxl 0 %endif -# Numactl is not available on s390[x] -%ifarch s390 s390x +# Numactl is not available on s390[x] and ARM +%ifarch s390 s390x %{arm} %define with_numactl 0 %endif -- 1.7.6.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] Problem with libvirt daemon
Hello, I have a problem with the libvirt daemon. I have a little php script which should connect with libvirt, but it won't. When I try to start the libvirt daemon I get this error (using the command libvirtd --listen): 2011-11-09 19:35:18.095: 3560: info : libvirt version: 0.9.7 2011-11-09 19:35:18.095: 3560: error : virPidFileAcquirePath:345 : Failed to acquire pid file '/var/run/libvirtd.pid': Resource temporarily unavailable So the daemon won't start and isn't started yet. If I check if the service is running with ps -ef | grep libvirtd I get this output: root 2865 1 0 15:50 ?00:00:00 /usr/sbin/libvirtd -d root 3149 1 0 19:17 ?00:00:00 libvirtd -d root 3206 1 0 19:17 ?00:00:00 libvirtd -dl root 3300 1 0 19:20 ?00:00:00 libvirtd --listen --daemon root 3356 1 0 19:21 ?00:00:00 libvirtd --listen --daemon root 3564 3077 0 19:36 pts/000:00:00 grep --color=auto libvirtd Here you can see that the service isn't running. How can I fix this problem. There is a .pid file in the /var/run/ directory. I already deleted it and used the command libvirtd -daemon -listen but it won't start. It doesn't show any output but when I use the ps -ef command, I see that the service is not running. Can you please help me? With kind regards, Wouter. -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 2/4] Refactor LXC network setup to allow future enhancements
On 11/10/2011 06:28 AM, Daniel P. Berrange wrote: From: "Daniel P. Berrange" The current lxcSetupInterfaces() method directly performs setup of the bridge devices. Since it will shortly need to also create macvlan devices, move the bridge related code into a separate method * src/lxc/lxc_driver.c: Split lxcSetupInterfaces() to create a new lxcSetupInterfaceBridge() --- src/lxc/lxc_driver.c | 167 + 1 files changed, 99 insertions(+), 68 deletions(-) diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index ccd8bad..4f6807b 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -1175,6 +1175,61 @@ static void lxcVmCleanup(lxc_driver_t *driver, } } + +static int lxcSetupInterfaceBridged(virConnectPtr conn, +virDomainNetDefPtr net, +const char *brname, +unsigned int *nveths, +char ***veths) +{ +int ret = -1; +char *parentVeth; +char *containerVeth = NULL; + +VIR_DEBUG("calling vethCreate()"); +parentVeth = net->ifname; +if (virNetDevVethCreate(&parentVeth,&containerVeth)< 0) +goto cleanup; +VIR_DEBUG("parentVeth: %s, containerVeth: %s", parentVeth, containerVeth); + +if (net->ifname == NULL) +net->ifname = parentVeth; + +if (VIR_REALLOC_N(*veths, (*nveths)+1)< 0) { +virReportOOMError(); +VIR_FREE(containerVeth); +goto cleanup; +} +(*veths)[(*nveths)] = containerVeth; +(*nveths)++; + +if (virNetDevSetMAC(containerVeth, net->mac)< 0) +goto cleanup; + +if (virNetDevBridgeAddPort(brname, parentVeth)< 0) +goto cleanup; + +if (virNetDevSetOnline(parentVeth, true)< 0) +goto cleanup; + +if (virNetDevBandwidthSet(net->ifname, + virDomainNetGetActualBandwidth(net))< 0) { +lxcError(VIR_ERR_INTERNAL_ERROR, + _("cannot set bandwidth limits on %s"), + net->ifname); +goto cleanup; +} + +if (net->filter&& +virDomainConfNWFilterInstantiate(conn, net)< 0) +goto cleanup; + +ret = 0; + +cleanup: +return ret; +} + /** * lxcSetupInterfaces: * @conn: pointer to connection @@ -1193,39 +1248,56 @@ static int lxcSetupInterfaces(virConnectPtr conn, unsigned int *nveths, char ***veths) { -int rc = -1, i; -char *bridge = NULL; +int ret = -1; +size_t i; for (i = 0 ; i< def->nnets ; i++) { -char *parentVeth; -char *containerVeth = NULL; - /* If appropriate, grab a physical device from the configured * network's pool of devices, or resolve bridge device name * to the one defined in the network definition. */ if (networkAllocateActualDevice(def->nets[i])< 0) -goto error_exit; +goto cleanup; switch (virDomainNetGetActualType(def->nets[i])) { -case VIR_DOMAIN_NET_TYPE_NETWORK: -{ +case VIR_DOMAIN_NET_TYPE_NETWORK: { virNetworkPtr network; +char *brname = NULL; -network = virNetworkLookupByName(conn, - def->nets[i]->data.network.name); -if (!network) { -goto error_exit; -} - -bridge = virNetworkGetBridgeName(network); +if (!(network = virNetworkLookupByName(conn, + def->nets[i]->data.network.name))) +goto cleanup; +brname = virNetworkGetBridgeName(network); virNetworkFree(network); +if (!brname) +goto cleanup; + +if (lxcSetupInterfaceBridged(conn, + def->nets[i], + brname, + nveths, + veths)< 0) { +VIR_FREE(brname); +goto cleanup; +} +VIR_FREE(brname); break; } -case VIR_DOMAIN_NET_TYPE_BRIDGE: -bridge = virDomainNetGetActualBridgeName(def->nets[i]); -break; +case VIR_DOMAIN_NET_TYPE_BRIDGE: { +const char *brname = virDomainNetGetActualBridgeName(def->nets[i]); +if (!brname) { +lxcError(VIR_ERR_INTERNAL_ERROR, "%s", + _("No bridge name specified")); +goto cleanup; +} +if (lxcSetupInterfaceBridged(conn, + def->nets[i], + brname, + nveths, + veths)< 0)
Re: [libvirt] [PATCH 1/4] Add missing 'const' annotations for internal domain conf helpers
On 11/10/2011 06:28 AM, Daniel P. Berrange wrote: From: "Daniel P. Berrange" The virDomainNetGetActualBridgeName and virDomainNetGetActualDirectDev methods both return strings that point to data in the virDomainDefPtr struct, and should therefore not be freed. The return values should thus be 'const char *' not 'char *'. * src/conf/domain_conf.c, src/conf/domain_conf.h: Mark const * src/network/bridge_driver.c: Update to use a const char * --- src/conf/domain_conf.c |4 ++-- src/conf/domain_conf.h |4 ++-- src/network/bridge_driver.c | 12 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 9528697..5a83dec 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -13046,7 +13046,7 @@ virDomainNetGetActualType(virDomainNetDefPtr iface) return iface->data.network.actual->type; } -char * +const char * virDomainNetGetActualBridgeName(virDomainNetDefPtr iface) { if (iface->type == VIR_DOMAIN_NET_TYPE_BRIDGE) @@ -13058,7 +13058,7 @@ virDomainNetGetActualBridgeName(virDomainNetDefPtr iface) return iface->data.network.actual->data.bridge.brname; } -char * +const char * virDomainNetGetActualDirectDev(virDomainNetDefPtr iface) { if (iface->type == VIR_DOMAIN_NET_TYPE_DIRECT) diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 9528199..4e86d30 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1794,8 +1794,8 @@ int virDomainGraphicsListenSetNetwork(virDomainGraphicsDefPtr def, ATTRIBUTE_NONNULL(1); int virDomainNetGetActualType(virDomainNetDefPtr iface); -char *virDomainNetGetActualBridgeName(virDomainNetDefPtr iface); -char *virDomainNetGetActualDirectDev(virDomainNetDefPtr iface); +const char *virDomainNetGetActualBridgeName(virDomainNetDefPtr iface); +const char *virDomainNetGetActualDirectDev(virDomainNetDefPtr iface); int virDomainNetGetActualDirectMode(virDomainNetDefPtr iface); virNetDevVPortProfilePtr virDomainNetGetActualDirectVirtPortProfile(virDomainNetDefPtr iface); diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 5dfc294..623e4b3 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -2898,7 +2898,7 @@ networkNotifyActualDevice(virDomainNetDefPtr iface) struct network_driver *driver = driverState; virNetworkObjPtr network; virNetworkDefPtr netdef; -char *actualDev; +const char *actualDev; int ret = -1; if (iface->type != VIR_DOMAIN_NET_TYPE_NETWORK) @@ -2924,8 +2924,8 @@ networkNotifyActualDevice(virDomainNetDefPtr iface) if (!actualDev) { networkReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("the interface uses a direct mode, but has no source dev")); -goto cleanup; -} +goto cleanup; +} netdef = network->def; if (netdef->nForwardIfs == 0) { @@ -2998,7 +2998,7 @@ networkReleaseActualDevice(virDomainNetDefPtr iface) struct network_driver *driver = driverState; virNetworkObjPtr network = NULL; virNetworkDefPtr netdef; -char *actualDev; +const char *actualDev; int ret = -1; if (iface->type != VIR_DOMAIN_NET_TYPE_NETWORK) @@ -3025,8 +3025,8 @@ networkReleaseActualDevice(virDomainNetDefPtr iface) if (!actualDev) { networkReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("the interface uses a direct mode, but has no source dev")); -goto cleanup; -} +goto cleanup; +} netdef = network->def; if (netdef->nForwardIfs == 0) { ACK -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 3/4] Allow creation of plain macvlan devices
On 11/10/2011 06:28 AM, Daniel P. Berrange wrote: From: "Daniel P. Berrange" Update virNetDevMacVLanCreateWithVPortProfile to allow creation of plain macvlan devices, as well as macvtap devices. The former is useful for LXC containers * src/qemu/qemu_command.c: Explicitly request a macvtap device * src/util/virnetdevmacvlan.c, src/util/virnetdevmacvlan.h: Add new flag to allow switching between macvlan and macvtap creation --- src/qemu/qemu_command.c |2 +- src/util/virnetdevmacvlan.c | 41 - src/util/virnetdevmacvlan.h |5 +++-- 3 files changed, 32 insertions(+), 16 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 6df1f83..2f01436 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -154,7 +154,7 @@ qemuPhysIfaceConnect(virDomainDefPtr def, net->ifname, net->mac, virDomainNetGetActualDirectDev(net), virDomainNetGetActualDirectMode(net), -vnet_hdr, def->uuid, +true, vnet_hdr, def->uuid, virDomainNetGetActualDirectVirtPortProfile(net), &res_ifname, vmop, driver->stateDir, diff --git a/src/util/virnetdevmacvlan.c b/src/util/virnetdevmacvlan.c index fe2f383..98b0f9a 100644 --- a/src/util/virnetdevmacvlan.c +++ b/src/util/virnetdevmacvlan.c @@ -72,11 +72,14 @@ VIR_ENUM_IMPL(virNetDevMacVLanMode, VIR_NETDEV_MACVLAN_MODE_LAST, # define MACVTAP_NAME_PREFIX "macvtap" # define MACVTAP_NAME_PATTERN "macvtap%d" +# define MACVLAN_NAME_PREFIX "macvlan" +# define MACVLAN_NAME_PATTERN "macvlan%d" + /** * virNetDevMacVLanCreate: * * @ifname: The name the interface is supposed to have; optional parameter - * @type: The type of device, i.e., "macvtap" + * @type: The type of device, i.e., "macvtap", "macvlan" * @macaddress: The MAC address of the device * @srcdev: The name of the 'link' device * @macvlan_mode: The macvlan mode to use @@ -458,14 +461,14 @@ static const uint32_t modeMap[VIR_NETDEV_MACVLAN_MODE_LAST] = { * interface will be stored into if everything succeeded. It is up * to the caller to free the string. * - * Returns file descriptor of the tap device in case of success, - * negative value otherwise with error reported. - * + * Returns file descriptor of the tap device in case of success with @withTap, + * otherwise returns 0; returns -1 on error. */ int virNetDevMacVLanCreateWithVPortProfile(const char *tgifname, const unsigned char *macaddress, const char *linkdev, enum virNetDevMacVLanMode mode, + bool withTap, int vnet_hdr, const unsigned char *vmuuid, virNetDevVPortProfilePtr virtPortProfile, @@ -474,7 +477,9 @@ int virNetDevMacVLanCreateWithVPortProfile(const char *tgifname, char *stateDir, virNetDevBandwidthPtr bandwidth) { -const char *type = "macvtap"; +const char *type = withTap ? "macvtap" : "macvlan"; +const char *prefix = withTap ? MACVTAP_NAME_PREFIX : MACVLAN_NAME_PREFIX; +const char *pattern = withTap ? MACVTAP_NAME_PATTERN : MACVLAN_NAME_PATTERN; int c, rc; char ifname[IFNAMSIZ]; int retries, do_retry = 0; @@ -505,8 +510,7 @@ int virNetDevMacVLanCreateWithVPortProfile(const char *tgifname, return -1; if (ret) { -if (STRPREFIX(tgifname, - MACVTAP_NAME_PREFIX)) { +if (STRPREFIX(tgifname, prefix)) { goto create_name; } virReportSystemError(EEXIST, @@ -522,7 +526,7 @@ int virNetDevMacVLanCreateWithVPortProfile(const char *tgifname, create_name: retries = 5; for (c = 0; c< 8192; c++) { -snprintf(ifname, sizeof(ifname), MACVTAP_NAME_PATTERN, c); +snprintf(ifname, sizeof(ifname), pattern, c); if ((ret = virNetDevExists(ifname))< 0) return -1; if (!ret) { @@ -553,15 +557,26 @@ create_name: goto disassociate_exit; } -rc = virNetDevMacVLanTapOpen(cr_ifname, 10); -if (rc>= 0) { +if (withTap) { +if ((rc = virNetDevMacVLanTapOpen(cr_ifname, 10))< 0) +goto disassociate_exit; + if (virNetDevMacVLanTapSetup(rc, vnet_hdr)< 0) { VIR_FORCE_CLOSE(rc); /* sets rc to -1 */ goto disassociate_exit; } -*res_ifname = strdup(cr_ifname); -} else -goto disassociate_exit; +if (!(*res_ifname = strdup(cr_ifname))) { +VIR_FORCE_CLOSE(rc); /* sets rc to -1 */ +virReportOOMError(); +
Re: [libvirt] [PATCH 4/4] Add support for interfaces with type=direct to LXC
On 11/10/2011 06:28 AM, Daniel P. Berrange wrote: From: "Daniel P. Berrange" Support creation of macvlan devices for LXC containers. Do not allow setting of network filters, bandwidth controls or vport profiles due to the complication that there is no host side visible device to work with. * src/lxc/lxc_driver.c: Support type=direct interfaces --- src/lxc/lxc_driver.c | 106 +- 1 files changed, 105 insertions(+), 1 deletions(-) diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 4f6807b..09752a3 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -1230,6 +1230,102 @@ cleanup: return ret; } + +static int lxcSetupInterfaceDirect(virConnectPtr conn, + virDomainDefPtr def, + virDomainNetDefPtr net, + unsigned int *nveths, + char ***veths) +{ +int ret = 0; +char *res_ifname = NULL; +lxc_driver_t *driver = conn->privateData; +virNetDevBandwidthPtr bw; +virNetDevVPortProfilePtr prof; + +/* XXX how todo filtering ? + * Since the 'net-ifname' is about to be moved to a different + * namespace& renamed, there will be no host side visible + * interface for the container to attach rules to + */ Afaik, filtering doesn't work on the direct interfaces anyway due to missing hooks in their kernel implementation. At least I have been told so about the macvtap type of device. +if (net->filter) { +lxcError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Unable to set network filters on direct interfaces")); +return -1; +} + +/* XXX how todo bandwidth controls ? + * Since the 'net-ifname' is about to be moved to a different + * namespace& renamed, there will be no host side visible + * interface for the container to attach rules to + */ +bw = virDomainNetGetActualBandwidth(net); +if (bw) { +lxcError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Unable to set network bandwidth on direct interfaces")); +return -1; +} + +/* XXX how todo port profiles ? + * Although we can do the association during container + * startup, at shutdown we are unable to disassociate + * because the macvlan device was moved to the container + * and automagically dies when the container dies. So + * we have no dev to perform disassociation with. + */ +prof = virDomainNetGetActualDirectVirtPortProfile(net); +if (prof) { +lxcError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Unable to set port profile on direct interfaces")); +return -1; +} + +if (VIR_REALLOC_N(*veths, (*nveths)+1)< 0) { +virReportOOMError(); +return -1; +} +(*veths)[(*nveths)] = NULL; + +if (virNetDevMacVLanCreateWithVPortProfile( +net->ifname, net->mac, +virDomainNetGetActualDirectDev(net), +virDomainNetGetActualDirectMode(net), +false, false, def->uuid, +virDomainNetGetActualDirectVirtPortProfile(net), +&res_ifname, +VIR_NETDEV_VPORT_PROFILE_OP_CREATE, +driver->stateDir, +virDomainNetGetActualBandwidth(net))< 0) +goto cleanup; + +(*veths)[(*nveths)] = res_ifname; +(*nveths)++; + +#if 0 +if (rc>= 0) { +if ((net->filter)&& (net->ifname)) { +err = virDomainConfNWFilterInstantiate(conn, net); +if (err) { +VIR_FORCE_CLOSE(rc); +ignore_value(virNetDevMacVLanDeleteWithVPortProfile( + net->ifname, net->mac, + virDomainNetGetActualDirectDev(net), + virDomainNetGetActualDirectMode(net), + virDomainNetGetActualDirectVirtPortProfile(net), + driver->stateDir)); +VIR_FREE(net->ifname); +} +} +} +#endif I think you can remove this block. + +ret = 0; + +cleanup: +return ret; +} + + /** * lxcSetupInterfaces: * @conn: pointer to connection @@ -1299,13 +1395,21 @@ static int lxcSetupInterfaces(virConnectPtr conn, goto cleanup; } break; +case VIR_DOMAIN_NET_TYPE_DIRECT: +if (lxcSetupInterfaceDirect(conn, +def, +def->nets[i], +nveths, +veths)< 0) +goto cleanup; +break; + case VIR_DOMAIN_NET_TYPE_USER: case VIR_DOMAIN_NET_TYPE_ETHERNET: case VIR_DOMAIN_NET_TYPE_SERVER: case VIR_DOMAIN_NET_TYPE_CLIENT: case VIR_DOMAIN_NET_TYPE_MCAST: case VIR_DOMAIN_NET_TYPE_INTERNAL: -
Re: [libvirt] Problem with libvirt daemon
On Thu, Nov 10, 2011 at 02:46:42PM +0100, Wouter - Iamotor wrote: > Hello, > > > > I have a problem with the libvirt daemon. I have a little php script which > should connect with libvirt, but it won't. > > > > When I try to start the libvirt daemon I get this error (using the command > libvirtd --listen): > > 2011-11-09 19:35:18.095: 3560: info : libvirt version: 0.9.7 > > 2011-11-09 19:35:18.095: 3560: error : virPidFileAcquirePath:345 : Failed to > acquire pid file '/var/run/libvirtd.pid': Resource temporarily unavailable > > > > So the daemon won't start and isn't started yet. If I check if the service > is running with ps -ef | grep libvirtd I get this output: > > root 2865 1 0 15:50 ?00:00:00 /usr/sbin/libvirtd -d > > root 3149 1 0 19:17 ?00:00:00 libvirtd -d > > root 3206 1 0 19:17 ?00:00:00 libvirtd -dl > > root 3300 1 0 19:20 ?00:00:00 libvirtd --listen --daemon > > root 3356 1 0 19:21 ?00:00:00 libvirtd --listen --daemon > > root 3564 3077 0 19:36 pts/000:00:00 grep --color=auto libvirtd > > > > Here you can see that the service isn't running. Err, that shows precisely the opposite of what you say. It shows that you have libvirtd running *5* times, no doubt due to you deleting the pidfiles. 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 0/5] Support Blkio tune, CPU tune, NUMA, CPU affinity in LXC
The following patch series brings the LXC driver upto parity with the QEMU driver in terms of support for various performance tuning controls -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 1/5] Refactor initial LXC mem tune / device ACL code
From: "Daniel P. Berrange" To make lxcSetContainerResources smaller, pull the mem tune I/O tune, CPU tune, and device ACL setup code out into separate methods * src/lxc/lxc_controller.c: Split up lxcSetContainerResources --- src/lxc/lxc_controller.c | 154 +++--- 1 files changed, 104 insertions(+), 50 deletions(-) diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c index 137ef52..d3c3b61 100644 --- a/src/lxc/lxc_controller.c +++ b/src/lxc/lxc_controller.c @@ -223,70 +223,49 @@ cleanup: return ret; } -/** - * lxcSetContainerResources - * @def: pointer to virtual machine structure - * - * Creates a cgroup for the container, moves the task inside, - * and sets resource limits - * - * Returns 0 on success or -1 in case of error - */ -static int lxcSetContainerResources(virDomainDefPtr def) +static int lxcSetContainerCpuTune(virCgroupPtr cgroup, virDomainDefPtr def) { -virCgroupPtr driver; -virCgroupPtr cgroup; -int rc = -1; -int i; -struct cgroup_device_policy devices[] = { -{'c', LXC_DEV_MAJ_MEMORY, LXC_DEV_MIN_NULL}, -{'c', LXC_DEV_MAJ_MEMORY, LXC_DEV_MIN_ZERO}, -{'c', LXC_DEV_MAJ_MEMORY, LXC_DEV_MIN_FULL}, -{'c', LXC_DEV_MAJ_MEMORY, LXC_DEV_MIN_RANDOM}, -{'c', LXC_DEV_MAJ_MEMORY, LXC_DEV_MIN_URANDOM}, -{'c', LXC_DEV_MAJ_TTY, LXC_DEV_MIN_TTY}, -{'c', LXC_DEV_MAJ_TTY, LXC_DEV_MIN_PTMX}, -{0, 0, 0}}; - -rc = virCgroupForDriver("lxc", &driver, 1, 0); -if (rc != 0) { -/* Skip all if no driver cgroup is configured */ -if (rc == -ENXIO || rc == -ENOENT) -return 0; - -virReportSystemError(-rc, "%s", - _("Unable to get cgroup for driver")); -return rc; -} - -rc = virCgroupForDomain(driver, def->name, &cgroup, 1); -if (rc != 0) { -virReportSystemError(-rc, - _("Unable to create cgroup for domain %s"), - def->name); -goto cleanup; -} - -if (def->blkio.weight) { -rc = virCgroupSetBlkioWeight(cgroup, def->blkio.weight); +int ret = -1; +if (def->cputune.shares != 0) { +int rc = virCgroupSetCpuShares(cgroup, def->cputune.shares); if (rc != 0) { virReportSystemError(-rc, - _("Unable to set Blkio weight for domain %s"), + _("Unable to set io cpu shares for domain %s"), def->name); goto cleanup; } } +ret = 0; +cleanup: +return ret; +} + -if (def->cputune.shares) { -rc = virCgroupSetCpuShares(cgroup, def->cputune.shares); +static int lxcSetContainerBlkioTune(virCgroupPtr cgroup, virDomainDefPtr def) +{ +int ret = -1; + +if (def->blkio.weight) { +int rc = virCgroupSetBlkioWeight(cgroup, def->blkio.weight); if (rc != 0) { virReportSystemError(-rc, - _("Unable to set cpu shares for domain %s"), + _("Unable to set Blkio weight for domain %s"), def->name); goto cleanup; } } +ret = 0; +cleanup: +return ret; +} + + +static int lxcSetContainerMemTune(virCgroupPtr cgroup, virDomainDefPtr def) +{ +int ret = -1; +int rc; + rc = virCgroupSetMemory(cgroup, def->mem.max_balloon); if (rc != 0) { virReportSystemError(-rc, @@ -325,6 +304,27 @@ static int lxcSetContainerResources(virDomainDefPtr def) } } +ret = 0; +cleanup: +return ret; +} + + +static int lxcSetContainerDeviceACL(virCgroupPtr cgroup, virDomainDefPtr def) +{ +int ret = -1; +int rc; +size_t i; +static const struct cgroup_device_policy devices[] = { +{'c', LXC_DEV_MAJ_MEMORY, LXC_DEV_MIN_NULL}, +{'c', LXC_DEV_MAJ_MEMORY, LXC_DEV_MIN_ZERO}, +{'c', LXC_DEV_MAJ_MEMORY, LXC_DEV_MIN_FULL}, +{'c', LXC_DEV_MAJ_MEMORY, LXC_DEV_MIN_RANDOM}, +{'c', LXC_DEV_MAJ_MEMORY, LXC_DEV_MIN_URANDOM}, +{'c', LXC_DEV_MAJ_TTY, LXC_DEV_MIN_TTY}, +{'c', LXC_DEV_MAJ_TTY, LXC_DEV_MIN_PTMX}, +{0, 0, 0}}; + rc = virCgroupDenyAllDevices(cgroup); if (rc != 0) { virReportSystemError(-rc, @@ -334,7 +334,7 @@ static int lxcSetContainerResources(virDomainDefPtr def) } for (i = 0; devices[i].type != 0; i++) { -struct cgroup_device_policy *dev = &devices[i]; +const struct cgroup_device_policy *dev = &devices[i]; rc = virCgroupAllowDevice(cgroup, dev->type, dev->major, @@ -374,6 +374,60 @@ static int lxcSetContainerResources(virDomainDefPtr def) goto cleanup; } +ret = 0; +cleanup: +return ret; +} + + +/** + * lxcSetContainerResources + * @def: pointer to virtua
[libvirt] [PATCH 4/5] Add support for CPU quota/period to LXC driver
From: "Daniel P. Berrange" * src/lxc/lxc_driver.c: Support changing quota/period for LXC containers * src/lxc/lxc_controller.c: Set initial quota/period at startup --- src/lxc/lxc_controller.c | 18 ++ src/lxc/lxc_driver.c | 459 -- 2 files changed, 425 insertions(+), 52 deletions(-) diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c index 2c387a5..dd4a334 100644 --- a/src/lxc/lxc_controller.c +++ b/src/lxc/lxc_controller.c @@ -394,6 +394,24 @@ static int lxcSetContainerCpuTune(virCgroupPtr cgroup, virDomainDefPtr def) goto cleanup; } } +if (def->cputune.quota != 0) { +int rc = virCgroupSetCpuCfsQuota(cgroup, def->cputune.quota); +if (rc != 0) { +virReportSystemError(-rc, + _("Unable to set io cpu quota for domain %s"), + def->name); +goto cleanup; +} +} +if (def->cputune.period != 0) { +int rc = virCgroupSetCpuCfsPeriod(cgroup, def->cputune.period); +if (rc != 0) { +virReportSystemError(-rc, + _("Unable to set io cpu period for domain %s"), + def->name); +goto cleanup; +} +} ret = 0; cleanup: return ret; diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index f945e2a..356a175 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -2493,84 +2493,324 @@ static int lxcVersion(virConnectPtr conn ATTRIBUTE_UNUSED, unsigned long *versio return 0; } -static char *lxcGetSchedulerType(virDomainPtr domain ATTRIBUTE_UNUSED, + +/* + * check whether the host supports CFS bandwidth + * + * Return 1 when CFS bandwidth is supported, 0 when CFS bandwidth is not + * supported, -1 on error. + */ +static int lxcGetCpuBWStatus(virCgroupPtr cgroup) +{ +char *cfs_period_path = NULL; +int ret = -1; + +if (!cgroup) +return 0; + +if (virCgroupPathOfController(cgroup, VIR_CGROUP_CONTROLLER_CPU, + "cpu.cfs_period_us", &cfs_period_path) < 0) { +VIR_INFO("cannot get the path of cgroup CPU controller"); +ret = 0; +goto cleanup; +} + +if (access(cfs_period_path, F_OK) < 0) { +ret = 0; +} else { +ret = 1; +} + +cleanup: +VIR_FREE(cfs_period_path); +return ret; +} + + +static bool lxcCgroupControllerActive(lxc_driver_t *driver, + int controller) +{ +if (driver->cgroup == NULL) +return false; +if (controller < 0 || controller >= VIR_CGROUP_CONTROLLER_LAST) +return false; +if (!virCgroupMounted(driver->cgroup, controller)) +return false; +return true; +} + + + +static char *lxcGetSchedulerType(virDomainPtr domain, int *nparams) { -char *schedulerType = NULL; +lxc_driver_t *driver = domain->conn->privateData; +char *ret = NULL; +int rc; -if (nparams) -*nparams = 1; +lxcDriverLock(driver); +if (!lxcCgroupControllerActive(driver, VIR_CGROUP_CONTROLLER_CPU)) { +lxcError(VIR_ERR_OPERATION_INVALID, + "%s", _("cgroup CPU controller is not mounted")); +goto cleanup; +} -schedulerType = strdup("posix"); +if (nparams) { +rc = lxcGetCpuBWStatus(driver->cgroup); +if (rc < 0) +goto cleanup; +else if (rc == 0) +*nparams = 1; +else +*nparams = 3; +} -if (schedulerType == NULL) +ret = strdup("posix"); +if (!ret) virReportOOMError(); -return schedulerType; +cleanup: +lxcDriverUnlock(driver); +return ret; +} + + +static int +lxcGetVcpuBWLive(virCgroupPtr cgroup, unsigned long long *period, + long long *quota) +{ +int rc; + +rc = virCgroupGetCpuCfsPeriod(cgroup, period); +if (rc < 0) { +virReportSystemError(-rc, "%s", + _("unable to get cpu bandwidth period tunable")); +return -1; +} + +rc = virCgroupGetCpuCfsQuota(cgroup, quota); +if (rc < 0) { +virReportSystemError(-rc, "%s", + _("unable to get cpu bandwidth tunable")); +return -1; +} + +return 0; +} + + +static int lxcSetVcpuBWLive(virCgroupPtr cgroup, unsigned long long period, +long long quota) +{ +int rc; +unsigned long long old_period; + +if (period == 0 && quota == 0) +return 0; + +if (period) { +/* get old period, and we can rollback if set quota failed */ +rc = virCgroupGetCpuCfsPeriod(cgroup, &old_period); +if (rc < 0) { +virReportSystemError(-rc, + "%s", _("Unable to get cpu bandwidth period")); +return -1; +} + +rc = virCgroupSetC
[libvirt] [PATCH 3/5] Support CPU placement in LXC driver
From: "Daniel P. Berrange" While LXC does not have the concept of VCPUS, so we cann't do per-VCPU pCPU placement, we can support the VM level CPU placement. Todo this simply set the CPU affinity of the LXC controller at startup. All child processes will inherit this affinity. * src/lxc/lxc_controller.c: Set process affinity --- src/lxc/lxc_controller.c | 62 ++ 1 files changed, 62 insertions(+), 0 deletions(-) diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c index 4f2326b..2c387a5 100644 --- a/src/lxc/lxc_controller.c +++ b/src/lxc/lxc_controller.c @@ -65,6 +65,8 @@ #include "virfile.h" #include "virpidfile.h" #include "command.h" +#include "processinfo.h" +#include "nodeinfo.h" #define VIR_FROM_THIS VIR_FROM_LXC @@ -323,6 +325,63 @@ static int lxcSetContainerNUMAPolicy(virDomainDefPtr def) #endif +/* + * To be run while still single threaded + */ +static int lxcSetContainerCpuAffinity(virDomainDefPtr def) +{ +int i, hostcpus, maxcpu = CPU_SETSIZE; +virNodeInfo nodeinfo; +unsigned char *cpumap; +int cpumaplen; + +VIR_DEBUG("Setting CPU affinity"); + +if (nodeGetInfo(NULL, &nodeinfo) < 0) +return -1; + +/* setaffinity fails if you set bits for CPUs which + * aren't present, so we have to limit ourselves */ +hostcpus = VIR_NODEINFO_MAXCPUS(nodeinfo); +if (maxcpu > hostcpus) +maxcpu = hostcpus; + +cpumaplen = VIR_CPU_MAPLEN(maxcpu); +if (VIR_ALLOC_N(cpumap, cpumaplen) < 0) { +virReportOOMError(); +return -1; +} + +if (def->cpumask) { +/* XXX why don't we keep 'cpumask' in the libvirt cpumap + * format to start with ?!?! */ +for (i = 0 ; i < maxcpu && i < def->cpumasklen ; i++) +if (def->cpumask[i]) +VIR_USE_CPU(cpumap, i); +} else { +/* You may think this is redundant, but we can't assume libvirtd + * itself is running on all pCPUs, so we need to explicitly set + * the spawned QEMU instance to all pCPUs if no map is given in + * its config file */ +for (i = 0 ; i < maxcpu ; i++) +VIR_USE_CPU(cpumap, i); +} + +/* We are pressuming we are running between fork/exec of QEMU + * so use '0' to indicate our own process ID. No threads are + * running at this point + */ +if (virProcessInfoSetAffinity(0, /* Self */ + cpumap, cpumaplen, maxcpu) < 0) { +VIR_FREE(cpumap); +return -1; +} +VIR_FREE(cpumap); + +return 0; +} + + static int lxcSetContainerCpuTune(virCgroupPtr cgroup, virDomainDefPtr def) { int ret = -1; @@ -541,6 +600,9 @@ static int lxcSetContainerResources(virDomainDefPtr def) * the cgroup, otherwise the 'cpuset' controller * will reset the values we've just defined! */ +if (lxcSetContainerCpuAffinity(def) < 0) +goto cleanup; + if (lxcSetContainerNUMAPolicy(def) < 0) goto cleanup; -- 1.7.6.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 4/4] Add support for interfaces with type=direct to LXC
On Thu, Nov 10, 2011 at 09:02:41AM -0500, Stefan Berger wrote: > On 11/10/2011 06:28 AM, Daniel P. Berrange wrote: > >From: "Daniel P. Berrange" > > > >Support creation of macvlan devices for LXC containers. Do not > >allow setting of network filters, bandwidth controls or vport > >profiles due to the complication that there is no host side > >visible device to work with. > > > >* src/lxc/lxc_driver.c: Support type=direct interfaces > >--- > > src/lxc/lxc_driver.c | 106 > > +- > > 1 files changed, 105 insertions(+), 1 deletions(-) > > > >diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c > >index 4f6807b..09752a3 100644 > >--- a/src/lxc/lxc_driver.c > >+++ b/src/lxc/lxc_driver.c > >@@ -1230,6 +1230,102 @@ cleanup: > > return ret; > > } > > > >+ > >+static int lxcSetupInterfaceDirect(virConnectPtr conn, > >+ virDomainDefPtr def, > >+ virDomainNetDefPtr net, > >+ unsigned int *nveths, > >+ char ***veths) > >+{ > >+int ret = 0; > >+char *res_ifname = NULL; > >+lxc_driver_t *driver = conn->privateData; > >+virNetDevBandwidthPtr bw; > >+virNetDevVPortProfilePtr prof; > >+ > >+/* XXX how todo filtering ? > >+ * Since the 'net-ifname' is about to be moved to a different > >+ * namespace& renamed, there will be no host side visible > >+ * interface for the container to attach rules to > >+ */ > Afaik, filtering doesn't work on the direct interfaces anyway due to > missing hooks in their kernel implementation. At least I have been > told so about the macvtap type of device. Oh, I wonder why the filtering controls are set for macvtap devices in the QEMU driver :-) 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/5] Support NUMA memory placement for LXC containers
From: "Daniel P. Berrange" Use numactl to set NUMA memory placement for LXC containers * src/lxc/lxc_controller.c: Support NUMA memory placement --- src/lxc/lxc_controller.c | 111 ++ 1 files changed, 111 insertions(+), 0 deletions(-) diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c index d3c3b61..4f2326b 100644 --- a/src/lxc/lxc_controller.c +++ b/src/lxc/lxc_controller.c @@ -48,6 +48,11 @@ # include #endif +#if HAVE_NUMACTL +# define NUMA_VERSION1_COMPATIBILITY 1 +# include +#endif + #include "virterror_internal.h" #include "logging.h" #include "util.h" @@ -223,6 +228,101 @@ cleanup: return ret; } + +#if HAVE_NUMACTL +static int lxcSetContainerNUMAPolicy(virDomainDefPtr def) +{ +nodemask_t mask; +int mode = -1; +int node = -1; +int ret = -1; +int i = 0; +int maxnode = 0; +bool warned = false; + +if (!def->numatune.memory.nodemask) +return 0; + +VIR_DEBUG("Setting NUMA memory policy"); + +if (numa_available() < 0) { +lxcError(VIR_ERR_CONFIG_UNSUPPORTED, + "%s", _("Host kernel is not aware of NUMA.")); +return -1; +} + +maxnode = numa_max_node() + 1; + +/* Convert nodemask to NUMA bitmask. */ +nodemask_zero(&mask); +for (i = 0; i < VIR_DOMAIN_CPUMASK_LEN; i++) { +if (def->numatune.memory.nodemask[i]) { +if (i > NUMA_NUM_NODES) { +lxcError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Host cannot support NUMA node %d"), i); +return -1; +} +if (i > maxnode && !warned) { +VIR_WARN("nodeset is out of range, there is only %d NUMA " + "nodes on host", maxnode); +warned = true; + } +nodemask_set(&mask, i); +} +} + +mode = def->numatune.memory.mode; + +if (mode == VIR_DOMAIN_NUMATUNE_MEM_STRICT) { +numa_set_bind_policy(1); +numa_set_membind(&mask); +numa_set_bind_policy(0); +} else if (mode == VIR_DOMAIN_NUMATUNE_MEM_PREFERRED) { +int nnodes = 0; +for (i = 0; i < NUMA_NUM_NODES; i++) { +if (nodemask_isset(&mask, i)) { +node = i; +nnodes++; +} +} + +if (nnodes != 1) { +lxcError(VIR_ERR_CONFIG_UNSUPPORTED, + "%s", _("NUMA memory tuning in 'preferred' mode " + "only supports single node")); +goto cleanup; +} + +numa_set_bind_policy(0); +numa_set_preferred(node); +} else if (mode == VIR_DOMAIN_NUMATUNE_MEM_INTERLEAVE) { +numa_set_interleave_mask(&mask); +} else { +lxcError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Unable to set NUMA policy %s"), + virDomainNumatuneMemModeTypeToString(mode)); +goto cleanup; +} + +ret = 0; + +cleanup: +return ret; +} +#else +static int lxcSetContainerNUMAPolicy(virDomainDefPtr def) +{ +if (def->numatune.memory.nodemask) { +lxcError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("NUMA policy is not available on this platform")); +return -1; +} + +return 0; +} +#endif + + static int lxcSetContainerCpuTune(virCgroupPtr cgroup, virDomainDefPtr def) { int ret = -1; @@ -435,6 +535,17 @@ static int lxcSetContainerResources(virDomainDefPtr def) getpid(), def->name); } +rc = -1; + +/* These must come *after* placing the task in + * the cgroup, otherwise the 'cpuset' controller + * will reset the values we've just defined! + */ +if (lxcSetContainerNUMAPolicy(def) < 0) +goto cleanup; + +rc = 0; + cleanup: virCgroupFree(&driver); virCgroupFree(&cgroup); -- 1.7.6.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 5/5] Add support for blkio tuning of LXC containers
From: "Daniel P. Berrange" * src/lxc/lxc_controller.c: Refactor setting of initial blkio tuning parameters * src/lxc/lxc_driver.c: Enable live change of blkio tuning --- src/lxc/lxc_driver.c | 283 ++ 1 files changed, 283 insertions(+), 0 deletions(-) diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 356a175..0edc703 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -2998,6 +2998,287 @@ lxcGetSchedulerParameters(virDomainPtr domain, return lxcGetSchedulerParametersFlags(domain, params, nparams, 0); } + +static int lxcDomainSetBlkioParameters(virDomainPtr dom, + virTypedParameterPtr params, + int nparams, + unsigned int flags) +{ +lxc_driver_t *driver = dom->conn->privateData; +int i; +virCgroupPtr group = NULL; +virDomainObjPtr vm = NULL; +virDomainDefPtr persistentDef = NULL; +int ret = -1; +bool isActive; + +virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | + VIR_DOMAIN_AFFECT_CONFIG, -1); +lxcDriverLock(driver); + +vm = virDomainFindByUUID(&driver->domains, dom->uuid); + +if (vm == NULL) { +lxcError(VIR_ERR_INTERNAL_ERROR, +_("No such domain %s"), dom->uuid); +goto cleanup; +} + +isActive = virDomainObjIsActive(vm); + +if (flags == VIR_DOMAIN_AFFECT_CURRENT) { +if (isActive) +flags = VIR_DOMAIN_AFFECT_LIVE; +else +flags = VIR_DOMAIN_AFFECT_CONFIG; +} + +if (flags & VIR_DOMAIN_AFFECT_LIVE) { +if (!isActive) { +lxcError(VIR_ERR_OPERATION_INVALID, + "%s", _("domain is not running")); +goto cleanup; +} + +if (!lxcCgroupControllerActive(driver, VIR_CGROUP_CONTROLLER_BLKIO)) { +lxcError(VIR_ERR_OPERATION_INVALID, _("blkio cgroup isn't mounted")); +goto cleanup; +} + +if (virCgroupForDomain(driver->cgroup, vm->def->name, &group, 0) != 0) { +lxcError(VIR_ERR_INTERNAL_ERROR, + _("cannot find cgroup for domain %s"), vm->def->name); +goto cleanup; +} +} + +if (flags & VIR_DOMAIN_AFFECT_CONFIG) { +if (!vm->persistent) { +lxcError(VIR_ERR_OPERATION_INVALID, "%s", + _("cannot change persistent config of a transient domain")); +goto cleanup; +} +if (!(persistentDef = virDomainObjGetPersistentDef(driver->caps, vm))) +goto cleanup; +} + +ret = 0; +if (flags & VIR_DOMAIN_AFFECT_LIVE) { +for (i = 0; i < nparams; i++) { +virTypedParameterPtr param = ¶ms[i]; + +if (STREQ(param->field, VIR_DOMAIN_BLKIO_WEIGHT)) { +int rc; +if (param->type != VIR_TYPED_PARAM_UINT) { +lxcError(VIR_ERR_INVALID_ARG, "%s", + _("invalid type for blkio weight tunable, expected a 'unsigned int'")); +ret = -1; +continue; +} + +if (params[i].value.ui > 1000 || params[i].value.ui < 100) { +lxcError(VIR_ERR_INVALID_ARG, "%s", + _("out of blkio weight range.")); +ret = -1; +continue; +} + +rc = virCgroupSetBlkioWeight(group, params[i].value.ui); +if (rc != 0) { +virReportSystemError(-rc, "%s", + _("unable to set blkio weight tunable")); +ret = -1; +} +} else { +lxcError(VIR_ERR_INVALID_ARG, + _("Parameter `%s' not supported"), param->field); +ret = -1; +} +} +} else if (flags & VIR_DOMAIN_AFFECT_CONFIG) { +/* Clang can't see that if we get here, persistentDef was set. */ +sa_assert(persistentDef); + +for (i = 0; i < nparams; i++) { +virTypedParameterPtr param = ¶ms[i]; + +if (STREQ(param->field, VIR_DOMAIN_BLKIO_WEIGHT)) { +if (param->type != VIR_TYPED_PARAM_UINT) { +lxcError(VIR_ERR_INVALID_ARG, "%s", + _("invalid type for blkio weight tunable, expected a 'unsigned int'")); +ret = -1; +continue; +} + +if (params[i].value.ui > 1000 || params[i].value.ui < 100) { +lxcError(VIR_ERR_INVALID_ARG, "%s", + _("out of blkio weight range.")); +ret = -1; +continue; +} + +persistentDef->blkio.weight = params[i].value.ui; +} else { +
Re: [libvirt] Problem with libvirt daemon
Hello, My bad, I thought it said that it was running but it that the daemon wasn't doing anything. Because when I try to run this php script: "team7",VIR_CRED_PASSPHRASE=>"password"); echo ("Connecting to libvirt (URI:$uri)\n"); $conn=libvirt_connect($uri,false,$credentials); if ($conn==false) { echo ("Libvirt last error: ".libvirt_get_last_error()."\n"); exit; } else { $hostname=libvirt_get_hostname($conn); echo ("hostname:$hostname\n"); echo ("Domain count: Active ".libvirt_get_active_domain_count($conn).",Inactive ".libvirt_get_inactive_domain_count($conn).", Total ".libvirt_get_domain_count($conn)."\n"); $domains=libvirt_list_domains($conn); foreach ($domains as $dom) { echo ("Name:\t".libvirt_domain_get_name($dom)."\n"); echo("UUID:\t".libvirt_domain_get_uuid_string($dom)."\n"); $dominfo=libvirt_domain_get_info($dom); print_r($dominfo); } } ?> The script can also be found on this link: http://phplibvirt.cybersales.cz/bightml.html Then I get this error: Connecting to libvirt (URI:qemu+tcp:///system) Libvirt last error: unable to connect to server at 'localhost:16509': Connection refused The user team7 is added to the group libvirtd and kvm. Which configuration is necessary so that the script could run on the server? Thanks for your help so far. With kind regards, Wouter. -Oorspronkelijk bericht- Van: Daniel P. Berrange [mailto:berra...@redhat.com] Verzonden: donderdag 10 november 2011 15:23 Aan: Wouter - Iamotor CC: libvirt-l...@redhat.com Onderwerp: Re: [libvirt] Problem with libvirt daemon On Thu, Nov 10, 2011 at 02:46:42PM +0100, Wouter - Iamotor wrote: > Hello, > > > > I have a problem with the libvirt daemon. I have a little php script > which should connect with libvirt, but it won't. > > > > When I try to start the libvirt daemon I get this error (using the > command libvirtd --listen): > > 2011-11-09 19:35:18.095: 3560: info : libvirt version: 0.9.7 > > 2011-11-09 19:35:18.095: 3560: error : virPidFileAcquirePath:345 : > Failed to acquire pid file '/var/run/libvirtd.pid': Resource > temporarily unavailable > > > > So the daemon won't start and isn't started yet. If I check if the > service is running with ps -ef | grep libvirtd I get this output: > > root 2865 1 0 15:50 ?00:00:00 /usr/sbin/libvirtd -d > > root 3149 1 0 19:17 ?00:00:00 libvirtd -d > > root 3206 1 0 19:17 ?00:00:00 libvirtd -dl > > root 3300 1 0 19:20 ?00:00:00 libvirtd --listen --daemon > > root 3356 1 0 19:21 ?00:00:00 libvirtd --listen --daemon > > root 3564 3077 0 19:36 pts/000:00:00 grep --color=auto libvirtd > > > > Here you can see that the service isn't running. Err, that shows precisely the opposite of what you say. It shows that you have libvirtd running *5* times, no doubt due to you deleting the pidfiles. 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] qemu: Remove code instantiating filters on direct interfaces
Remove code that instantiates network filters on direct type of interfaces. The parser already does not accept filters on those type of interfaces. --- src/qemu/qemu_command.c | 26 +- src/qemu/qemu_command.h |1 - src/qemu/qemu_hotplug.c |2 +- 3 files changed, 2 insertions(+), 27 deletions(-) Index: libvirt-acl/src/qemu/qemu_command.c === --- libvirt-acl.orig/src/qemu/qemu_command.c +++ libvirt-acl/src/qemu/qemu_command.c @@ -135,7 +135,6 @@ uname_normalize (struct utsname *ut) */ int qemuPhysIfaceConnect(virDomainDefPtr def, - virConnectPtr conn, struct qemud_driver *driver, virDomainNetDefPtr net, virBitmapPtr qemuCaps, @@ -145,7 +144,6 @@ qemuPhysIfaceConnect(virDomainDefPtr def #if WITH_MACVTAP char *res_ifname = NULL; int vnet_hdr = 0; -int err; if (qemuCapsGet(qemuCaps, QEMU_CAPS_VNET_HDR) && net->model && STREQ(net->model, "virtio")) @@ -165,28 +163,6 @@ qemuPhysIfaceConnect(virDomainDefPtr def net->ifname = res_ifname; } -if (rc >=0 && driver->macFilter) { -if ((err = networkAllowMacOnPort(driver, net->ifname, net->mac))) { -virReportSystemError(err, - _("failed to add ebtables rule to allow MAC address on '%s'"), - net->ifname); -} -} - -if (rc >= 0) { -if ((net->filter) && (net->ifname)) { -err = virDomainConfNWFilterInstantiate(conn, net); -if (err) { -VIR_FORCE_CLOSE(rc); -delMacvtap(net->ifname, net->mac, - virDomainNetGetActualDirectDev(net), - virDomainNetGetActualDirectMode(net), - virDomainNetGetActualDirectVirtPortProfile(net), - driver->stateDir); -VIR_FREE(net->ifname); -} -} -} #else (void)def; (void)conn; @@ -4173,7 +4149,7 @@ qemuBuildCommandLine(virConnectPtr conn, tapfd) >= sizeof(tapfd_name)) goto no_memory; } else if (actualType == VIR_DOMAIN_NET_TYPE_DIRECT) { -int tapfd = qemuPhysIfaceConnect(def, conn, driver, net, +int tapfd = qemuPhysIfaceConnect(def, driver, net, qemuCaps, vmop); if (tapfd < 0) goto error; Index: libvirt-acl/src/qemu/qemu_command.h === --- libvirt-acl.orig/src/qemu/qemu_command.h +++ libvirt-acl/src/qemu/qemu_command.h @@ -132,7 +132,6 @@ int qemuNetworkIfaceConnect(virDomainDef ATTRIBUTE_NONNULL(2); int qemuPhysIfaceConnect(virDomainDefPtr def, - virConnectPtr conn, struct qemud_driver *driver, virDomainNetDefPtr net, virBitmapPtr qemuCaps, Index: libvirt-acl/src/qemu/qemu_hotplug.c === --- libvirt-acl.orig/src/qemu/qemu_hotplug.c +++ libvirt-acl/src/qemu/qemu_hotplug.c @@ -676,7 +676,7 @@ int qemuDomainAttachNetDevice(virConnect if (qemuOpenVhostNet(vm->def, net, priv->qemuCaps, &vhostfd) < 0) goto cleanup; } else if (actualType == VIR_DOMAIN_NET_TYPE_DIRECT) { -if ((tapfd = qemuPhysIfaceConnect(vm->def, conn, driver, net, +if ((tapfd = qemuPhysIfaceConnect(vm->def, driver, net, priv->qemuCaps, VIR_VM_OP_CREATE)) < 0) goto cleanup; -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 4/4] Add support for interfaces with type=direct to LXC
On 11/10/2011 09:32 AM, Daniel P. Berrange wrote: On Thu, Nov 10, 2011 at 09:02:41AM -0500, Stefan Berger wrote: On 11/10/2011 06:28 AM, Daniel P. Berrange wrote: From: "Daniel P. Berrange" Support creation of macvlan devices for LXC containers. Do not allow setting of network filters, bandwidth controls or vport profiles due to the complication that there is no host side visible device to work with. * src/lxc/lxc_driver.c: Support type=direct interfaces --- src/lxc/lxc_driver.c | 106 +- 1 files changed, 105 insertions(+), 1 deletions(-) diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 4f6807b..09752a3 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -1230,6 +1230,102 @@ cleanup: return ret; } + +static int lxcSetupInterfaceDirect(virConnectPtr conn, + virDomainDefPtr def, + virDomainNetDefPtr net, + unsigned int *nveths, + char ***veths) +{ +int ret = 0; +char *res_ifname = NULL; +lxc_driver_t *driver = conn->privateData; +virNetDevBandwidthPtr bw; +virNetDevVPortProfilePtr prof; + +/* XXX how todo filtering ? + * Since the 'net-ifname' is about to be moved to a different + * namespace& renamed, there will be no host side visible + * interface for the container to attach rules to + */ Afaik, filtering doesn't work on the direct interfaces anyway due to missing hooks in their kernel implementation. At least I have been told so about the macvtap type of device. Oh, I wonder why the filtering controls are set for macvtap devices in the QEMU driver :-) I will remove that. The parser already doesn't accept filters on direct interfaces. Stefan Daniel -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] qemu: Remove code instantiating filters on direct interfaces
On Thu, Nov 10, 2011 at 10:12:01AM -0500, Stefan Berger wrote: > Remove code that instantiates network filters on direct type > of interfaces. The parser already does not accept filters on > those type of interfaces. > > --- > src/qemu/qemu_command.c | 26 +- > src/qemu/qemu_command.h |1 - > src/qemu/qemu_hotplug.c |2 +- > 3 files changed, 2 insertions(+), 27 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] [PATCH 1/8] Add new API virDomain{Set, Get}BlockIoTune
On 11/09/2011 11:11 PM, Xu He Jie wrote: +++ b/include/libvirt/libvirt.h.in @@ -1640,6 +1640,32 @@ int virDomainBlockJobSetSpeed(virDomainPtr dom, const char *path, int virDomainBlockPull(virDomainPtr dom, const char *path, unsigned long bandwidth, unsigned int flags); +/* + * Block I/O throttling support + */ + +typedef struct _virDomainBlockIoTuneInfo virDomainBlockIoTuneInfo; +struct _virDomainBlockIoTuneInfo { This is not extensible. We've already learned the hard way that this MUST use virTypedParameter to make future additions painless, rather than hard-coding a particular structure. virTypedParameter is used between libvirt client and libvirtd. It isn't used between libvirtd and qemu. Correct - the public interface must use virTypedParameter. Once we get to qemu_driver.c, we can then convert from virTypedParameter to a struct specific to qemu, but that struct should probably be declared in qemu_monitor.h, and certainly NOT declared in libvirt.h.in. Qemu monitor send all the setting parameters at one time within qmp command made by qemuMonitorJSONMakeCommand, the union struct virTypeParameter is not very suitable for it. So we still use struct virDomainBlockIoTuneInfo to keep consistent for qemu monitor command. I have no problems with qemu monitor using a struct, my heartburn was with the introduction of a new public struct. -- Eric Blake ebl...@redhat.com+1-801-349-2682 Libvirt virtualization library http://libvirt.org -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] qemu: Remove code instantiating filters on direct interfaces
On 11/10/2011 10:14 AM, Daniel P. Berrange wrote: On Thu, Nov 10, 2011 at 10:12:01AM -0500, Stefan Berger wrote: Remove code that instantiates network filters on direct type of interfaces. The parser already does not accept filters on those type of interfaces. --- src/qemu/qemu_command.c | 26 +- src/qemu/qemu_command.h |1 - src/qemu/qemu_hotplug.c |2 +- 3 files changed, 2 insertions(+), 27 deletions(-) ACK Daniel Pushed -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] 0.9.7 virsh console regression?
On Wed, Nov 09, 2011 at 06:26:41PM -0500, Albert W. Hopkins wrote: > Hi folks, > > I have a few "headless" qemu domains that use serial consoles. > Typically i connect to the consoles with > > # virsh console > > However with 0.9.7 I get > > Connected to domain gentoo-base > Escape character is ^] > error: internal error character device (null) is not using a PTY I am seeing this error as well with the current git HEAD a132fb092574843d104d227d5ead7c5dfcc74850 Dave > I am still able to connect to the console if i go into the virt-manager > gui and use the "gui" console, but I'd rather not do that as sometimes I > don't have access to the gui. > > Is this a regression or am I expected to do some kind of migration on my > domains. These are qemu guests running on Gentoo Linux. An xml dump of > a typical domain follows: > > > base > b4a528dd-4c31-03ca-bdde-795c4c38592d > 524288 > 61440 > 1 > > hvm > /var/lib/libvirt/images/vmlinuz > root=/dev/vda1 rootfstype=ext4 quiet console=ttyS0 > TERM=vt100 > > > > > > > > > Nehalem > Intel > > > > > > > > > > > > > > > > > > destroy > restart > restart > > /usr/bin/qemu-kvm > > > > >function='0x0'/> > > > > >function='0x0'/> > > > > > > > > >function='0x0'/> > > > > > > Thanks in advance, > -a > > > -- > 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] [PATCH 1/8] Add new API virDomain{Set, Get}BlockIoTune
On Thu, Nov 10, 2011 at 04:32:51AM +0800, Lei HH Li wrote: > This patch add new pulic API virDomainSetBlockIoTune and > virDomainGetBlockIoTune. > > > Signed-off-by: Zhi Yong Wu > Signed-off-by: Lei Li > --- > include/libvirt/libvirt.h.in | 26 + > src/driver.h | 19 +++ > src/libvirt.c| 115 > ++ > src/libvirt_public.syms |2 + > 4 files changed, 162 insertions(+), 0 deletions(-) > > diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in > index aa320b6..a79c35e 100644 > --- a/include/libvirt/libvirt.h.in > +++ b/include/libvirt/libvirt.h.in > @@ -1640,6 +1640,32 @@ intvirDomainBlockJobSetSpeed(virDomainPtr dom, > const char *path, > int virDomainBlockPull(virDomainPtr dom, const char *path, > unsigned long bandwidth, unsigned int > flags); > > +/* > + * Block I/O throttling support > + */ > + > +typedef struct _virDomainBlockIoTuneInfo virDomainBlockIoTuneInfo; > +struct _virDomainBlockIoTuneInfo { > +unsigned long long total_bytes_sec; > +unsigned long long read_bytes_sec; > +unsigned long long write_bytes_sec; > +unsigned long long total_iops_sec; > +unsigned long long read_iops_sec; > +unsigned long long write_iops_sec; > +}; > +typedef virDomainBlockIoTuneInfo *virDomainBlockIoTuneInfoPtr; > + > +int > +virDomainSetBlockIoTune(virDomainPtr dom, > +const char *disk, > +virDomainBlockIoTuneInfoPtr info, > +unsigned int flags); > +int > +virDomainGetBlockIoTune(virDomainPtr dom, > +const char *disk, > +virDomainBlockIoTuneInfoPtr reply, > +unsigned int flags); > + > > /* > * NUMA support > diff --git a/src/driver.h b/src/driver.h > index 4c14aaa..9628ad7 100644 > --- a/src/driver.h > +++ b/src/driver.h > @@ -741,6 +741,23 @@ typedef int > unsigned long bandwidth, unsigned int flags); > > > +/* > + * Block I/O throttling support > + */ > + > +typedef int > +(*virDrvDomainSetBlockIoTune)(virDomainPtr dom, > + const char *disk, > + virDomainBlockIoTuneInfoPtr info, > + unsigned int flags); > + > +typedef int > +(*virDrvDomainGetBlockIoTune)(virDomainPtr dom, > + const char *disk, > + virDomainBlockIoTuneInfoPtr reply, > + unsigned int flags); > + > + > /** > * _virDriver: > * > @@ -899,6 +916,8 @@ struct _virDriver { > virDrvDomainGetBlockJobInfo domainGetBlockJobInfo; > virDrvDomainBlockJobSetSpeed domainBlockJobSetSpeed; > virDrvDomainBlockPull domainBlockPull; > +virDrvDomainSetBlockIoTune domainSetBlockIoTune; > +virDrvDomainGetBlockIoTune domainGetBlockIoTune; > }; > > typedef int > diff --git a/src/libvirt.c b/src/libvirt.c > index b0d1e01..79ac84d 100644 > --- a/src/libvirt.c > +++ b/src/libvirt.c > @@ -17083,3 +17083,118 @@ error: > virDispatchError(dom->conn); > return -1; > } > + > +/** > + * virDomainSetBlockIoTune: > + * @dom: pointer to domain object > + * @disk: Fully-qualified disk name > + * @info: Specify block I/O limits in bytes > + * @flags: An OR'ed set of virDomainModificationImpact > + * > + * This function is mainly to enable Block I/O throttling function in > libvirt. > + * It is used to change the block I/O throttling setting for specified > domain. > + * > + * Returns 0 if the operation has started, -1 on failure. > + */ > +int virDomainSetBlockIoTune(virDomainPtr dom, > +const char *disk, > +virDomainBlockIoTuneInfoPtr info, > +unsigned int flags) > +{ > +virConnectPtr conn; > + > +VIR_DOMAIN_DEBUG(dom, "disk=%p, info=%p, flags=%x", > + disk, info, flags); > + > +virResetLastError(); > + > +if (!VIR_IS_CONNECTED_DOMAIN (dom)) { > +virLibDomainError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__); > +virDispatchError(NULL); > +return -1; > +} > +conn = dom->conn; > + > +if (dom->conn->flags & VIR_CONNECT_RO) { > +virLibDomainError(VIR_ERR_OPERATION_DENIED, __FUNCTION__); > +goto error; > +} > + > +if (!disk) { > +virLibDomainError(VIR_ERR_INVALID_ARG, __FUNCTION__); > +goto error; > +} > + > +if (!info) { > +virLibDomainError(VIR_ERR_INVALID_ARG, __FUNCTION__); > +goto error; > +} > + > +if (conn->driver->domainSetBlockIoTune) { > +int ret; > +ret = conn->driver->domainSetBlockIoTune(dom, disk, info, flags); > +if (ret < 0) > +goto error; > +return ret; > +} > + > +virLibDomainError(VI
Re: [libvirt] [PATCH 2/8] Add virDomain{Set, Get}BlockIoTune support to the remote driver
Looks good to me. On Thu, Nov 10, 2011 at 04:32:52AM +0800, Lei HH Li wrote: > Support Block I/O Throttle setting and query to remote driver. > > Signed-off-by: Zhi Yong Wu > Signed-off-by: Lei Li > --- > daemon/remote.c | 87 > ++ > src/remote/remote_driver.c | 80 ++ > src/remote/remote_protocol.x | 38 ++- > src/remote_protocol-structs | 33 > 4 files changed, 237 insertions(+), 1 deletions(-) > > diff --git a/daemon/remote.c b/daemon/remote.c > index bd0c3e3..070ca65 100644 > --- a/daemon/remote.c > +++ b/daemon/remote.c > @@ -1850,6 +1850,93 @@ cleanup: > return rv; > } > > +static int > +remoteDispatchDomainSetBlockIoThrottle(virNetServerPtr server > ATTRIBUTE_UNUSED, > + virNetServerClientPtr client > ATTRIBUTE_UNUSED, > + virNetMessagePtr hdr ATTRIBUTE_UNUSED, > + virNetMessageErrorPtr rerr, > + > remote_domain_set_block_io_throttle_args *args) > +{ > +virDomainPtr dom = NULL; > +virDomainBlockIoTuneInfo tmp; > +int rv = -1; > +struct daemonClientPrivate *priv = > +virNetServerClientGetPrivateData(client); > + > +if (!priv->conn) { > +virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); > +goto cleanup; > +} > + > +if (!(dom = get_nonnull_domain(priv->conn, args->dom))) > +goto cleanup; > + > +if (args) { > +tmp.total_bytes_sec = args->bps; > +tmp.read_bytes_sec = args->bps_rd; > +tmp.write_bytes_sec = args->bps_wr; > +tmp.total_iops_sec = args->iops; > +tmp.read_iops_sec = args->iops_rd; > +tmp.write_iops_sec = args->iops_wr; > +} > + > +rv = virDomainSetBlockIoTune(dom, args->disk, &tmp, args->flags); > + > +if (rv < 0) > +goto cleanup; > + > +cleanup: > +if (rv < 0) > +virNetMessageSaveError(rerr); > +if (dom) > +virDomainFree(dom); > +return rv; > +} > + > +static int > +remoteDispatchDomainGetBlockIoThrottle(virNetServerPtr server > ATTRIBUTE_UNUSED, > + virNetServerClientPtr client > ATTRIBUTE_UNUSED, > + virNetMessagePtr hdr ATTRIBUTE_UNUSED, > + virNetMessageErrorPtr rerr, > + > remote_domain_get_block_io_throttle_args *args, > + > remote_domain_get_block_io_throttle_ret *ret) > +{ > +virDomainPtr dom = NULL; > +virDomainBlockIoTuneInfo reply; > +int rv = -1; > +struct daemonClientPrivate *priv = > +virNetServerClientGetPrivateData(client); > + > +if (!priv->conn) { > +virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); > +goto cleanup; > +} > + > +if (!(dom = get_nonnull_domain(priv->conn, args->dom))) > +goto cleanup; > + > +rv = virDomainGetBlockIoTune(dom, args->disk, &reply, args->flags); > + > +if (rv < 0) { > +ret->found = 0; > +goto cleanup; > +} > + > +ret->bps = reply.total_bytes_sec; > +ret->bps_rd = reply.read_bytes_sec; > +ret->bps_wr = reply.write_bytes_sec; > +ret->iops= reply.total_iops_sec; > +ret->iops_rd = reply.read_iops_sec; > +ret->iops_wr = reply.write_iops_sec; > +ret->found = 1; > + > +cleanup: > +if (rv < 0) > +virNetMessageSaveError(rerr); > +if (dom) > +virDomainFree(dom); > +return rv; > +} > > /*-*/ > > diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c > index f3b8ad5..0900231 100644 > --- a/src/remote/remote_driver.c > +++ b/src/remote/remote_driver.c > @@ -2154,6 +2154,84 @@ done: > return rv; > } > > +static int remoteDomainSetBlockIoTune(virDomainPtr domain, > + const char *disk, > + virDomainBlockIoTuneInfoPtr info, > + unsigned int flags) > +{ > +int rv = -1; > +remote_domain_set_block_io_throttle_args args; > +struct private_data *priv = domain->conn->privateData; > + > +remoteDriverLock(priv); > + > +memset(&args, 0, sizeof(args)); > + > +make_nonnull_domain(&args.dom, domain); > +args.disk = (char *)disk; > +args.bps = info->total_bytes_sec; > +args.bps_rd = info->read_bytes_sec; > +args.bps_wr = info->write_bytes_sec; > +args.iops = info->total_iops_sec; > +args.iops_rd = info->read_iops_sec; > +args.iops_wr = info->write_iops_sec; > +args.flags = flags; > + > +if (call(domain->conn, priv, 0, REMOTE_PROC_DOMAIN_SET_BLOCK_IO_THROTTLE, > + (xdrproc_t) xdr_remo
Re: [libvirt] Problem with libvirt daemon
(Please don't top-post when replying to messages on the list - it makes it more difficult to determine the context of what's being said as the thread gets longer.) On 11/10/2011 09:39 AM, Wouter - Iamotor wrote: Hello, My bad, I thought it said that it was running but it that the daemon wasn't doing anything. Because when I try to run this php script: "team7",VIR_CRED_PASSPHRASE=>"password"); echo ("Connecting to libvirt (URI:$uri)\n"); $conn=libvirt_connect($uri,false,$credentials); if ($conn==false) { echo ("Libvirt last error: ".libvirt_get_last_error()."\n"); exit; } else { $hostname=libvirt_get_hostname($conn); echo ("hostname:$hostname\n"); echo ("Domain count: Active ".libvirt_get_active_domain_count($conn).",Inactive ".libvirt_get_inactive_domain_count($conn).", Total ".libvirt_get_domain_count($conn)."\n"); $domains=libvirt_list_domains($conn); foreach ($domains as $dom) { echo ("Name:\t".libvirt_domain_get_name($dom)."\n"); echo("UUID:\t".libvirt_domain_get_uuid_string($dom)."\n"); $dominfo=libvirt_domain_get_info($dom); print_r($dominfo); } } ?> The script can also be found on this link: http://phplibvirt.cybersales.cz/bightml.html Then I get this error: Connecting to libvirt (URI:qemu+tcp:///system) Libvirt last error: unable to connect to server at 'localhost:16509': Connection refused The user team7 is added to the group libvirtd and kvm. Which configuration is necessary so that the script could run on the server? Thanks for your help so far. With kind regards, Wouter. -Oorspronkelijk bericht- Van: Daniel P. Berrange [mailto:berra...@redhat.com] Verzonden: donderdag 10 november 2011 15:23 Aan: Wouter - Iamotor CC: libvirt-l...@redhat.com Onderwerp: Re: [libvirt] Problem with libvirt daemon On Thu, Nov 10, 2011 at 02:46:42PM +0100, Wouter - Iamotor wrote: Hello, I have a problem with the libvirt daemon. I have a little php script which should connect with libvirt, but it won't. When I try to start the libvirt daemon I get this error (using the command libvirtd --listen): 2011-11-09 19:35:18.095: 3560: info : libvirt version: 0.9.7 2011-11-09 19:35:18.095: 3560: error : virPidFileAcquirePath:345 : Failed to acquire pid file '/var/run/libvirtd.pid': Resource temporarily unavailable So the daemon won't start and isn't started yet. If I check if the service is running with ps -ef | grep libvirtd I get this output: root 2865 1 0 15:50 ?00:00:00 /usr/sbin/libvirtd -d root 3149 1 0 19:17 ?00:00:00 libvirtd -d root 3206 1 0 19:17 ?00:00:00 libvirtd -dl root 3300 1 0 19:20 ?00:00:00 libvirtd --listen --daemon root 3356 1 0 19:21 ?00:00:00 libvirtd --listen --daemon root 3564 3077 0 19:36 pts/000:00:00 grep --color=auto libvirtd Here you can see that the service isn't running. Err, that shows precisely the opposite of what you say. It shows that you have libvirtd running *5* times, no doubt due to you deleting the pidfiles. Daniel -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] Problem with libvirt daemon
On 11/10/2011 09:39 AM, Wouter - Iamotor wrote: Hello, My bad, I thought it said that it was running but it that the daemon wasn't doing anything. Because when I try to run this php script: Instead of that uri, try this one: "qemu:///system". And if you want to connect to virsh on some other host "remotehost", use this uri: qemu+ssh://root@remotehost/system $credentials=Array(VIR_CRED_AUTHNAME=>"team7",VIR_CRED_PASSPHRASE=>"password"); echo ("Connecting to libvirt (URI:$uri)\n"); $conn=libvirt_connect($uri,false,$credentials); if ($conn==false) { echo ("Libvirt last error: ".libvirt_get_last_error()."\n"); exit; } else { $hostname=libvirt_get_hostname($conn); echo ("hostname:$hostname\n"); echo ("Domain count: Active ".libvirt_get_active_domain_count($conn).",Inactive ".libvirt_get_inactive_domain_count($conn).", Total ".libvirt_get_domain_count($conn)."\n"); $domains=libvirt_list_domains($conn); foreach ($domains as $dom) { echo ("Name:\t".libvirt_domain_get_name($dom)."\n"); echo("UUID:\t".libvirt_domain_get_uuid_string($dom)."\n"); $dominfo=libvirt_domain_get_info($dom); print_r($dominfo); } } ?> The script can also be found on this link: http://phplibvirt.cybersales.cz/bightml.html Then I get this error: Connecting to libvirt (URI:qemu+tcp:///system) Libvirt last error: unable to connect to server at 'localhost:16509': Connection refused The user team7 is added to the group libvirtd and kvm. Which configuration is necessary so that the script could run on the server? Thanks for your help so far. With kind regards, Wouter. -Oorspronkelijk bericht- Van: Daniel P. Berrange [mailto:berra...@redhat.com] Verzonden: donderdag 10 november 2011 15:23 Aan: Wouter - Iamotor CC: libvirt-l...@redhat.com Onderwerp: Re: [libvirt] Problem with libvirt daemon On Thu, Nov 10, 2011 at 02:46:42PM +0100, Wouter - Iamotor wrote: Hello, I have a problem with the libvirt daemon. I have a little php script which should connect with libvirt, but it won't. When I try to start the libvirt daemon I get this error (using the command libvirtd --listen): 2011-11-09 19:35:18.095: 3560: info : libvirt version: 0.9.7 2011-11-09 19:35:18.095: 3560: error : virPidFileAcquirePath:345 : Failed to acquire pid file '/var/run/libvirtd.pid': Resource temporarily unavailable So the daemon won't start and isn't started yet. If I check if the service is running with ps -ef | grep libvirtd I get this output: root 2865 1 0 15:50 ?00:00:00 /usr/sbin/libvirtd -d root 3149 1 0 19:17 ?00:00:00 libvirtd -d root 3206 1 0 19:17 ?00:00:00 libvirtd -dl root 3300 1 0 19:20 ?00:00:00 libvirtd --listen --daemon root 3356 1 0 19:21 ?00:00:00 libvirtd --listen --daemon root 3564 3077 0 19:36 pts/000:00:00 grep --color=auto libvirtd Here you can see that the service isn't running. Err, that shows precisely the opposite of what you say. It shows that you have libvirtd running *5* times, no doubt due to you deleting the pidfiles. Daniel -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [Qemu-devel] qemu and qemu.git -> Migration + disk stress introduces qcow2 corruptions
On 11/10/2011 02:55 AM, Avi Kivity wrote: On 11/09/2011 07:35 PM, Anthony Liguori wrote: On 11/09/2011 11:02 AM, Avi Kivity wrote: On 11/09/2011 06:39 PM, Anthony Liguori wrote: Migration with qcow2 is not a supported feature for 1.0. Migration is only supported with raw images using coherent shared storage[1]. [1] NFS is only coherent with close-to-open which right now is not good enough for migration. Say what? Due to block format probing, we read at least the first sector of the disk during start up. Strictly going by what NFS guarantees, since we don't open on the destination *after* as close on the source, we aren't guaranteed to see what's written by the source. In practice, because of block format probing, unless we're using cache=none, the first sector can be out of sync with the source on the destination. If you use cache=none on a Linux client with at least a Linux NFS server, you should be relatively safe. IMO, this should be a release blocker. qemu 1.0 only supporting migration on enterprise storage? If we have to delay the release for a month to get it right, we should. Not that I think we have to. Adding libvirt to the discussion. What does libvirt actually do in the monitor prior to migration completing on the destination? The least invasive way of doing delayed open of block devices is probably to make -incoming create a monitor and run a main loop before the block devices (and full device model) is initialized. Since this isolates the changes strictly to migration, I'd feel okay doing this for 1.0 (although it might need to be in the stable branch). I know a monitor can run like this as I've done it before but some of the commands will not behave as expected so it's pretty important to be comfortable with what commands are actually being used in this mode. Regards, Anthony Liguori -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [Qemu-devel] qemu and qemu.git -> Migration + disk stress introduces qcow2 corruptions
On Thu, Nov 10, 2011 at 12:27:30PM -0600, Anthony Liguori wrote: > What does libvirt actually do in the monitor prior to migration > completing on the destination? The least invasive way of doing > delayed open of block devices is probably to make -incoming create a > monitor and run a main loop before the block devices (and full > device model) is initialized. Since this isolates the changes > strictly to migration, I'd feel okay doing this for 1.0 (although it > might need to be in the stable branch). The way migration works with libvirt wrt QEMU interactions is now as follows 1. Destination. Run qemu -incoming ...args... Query chardevs via monitor Query vCPU threads via monitor Set disk / vnc passwords Set netdev link states Set balloon target 2. Source Set migration speed Set migration max downtime Run migrate command (detached) while 1 Query migration status if status is failed or success break; 3. Destination If final status was success Run 'cont' in monitor else kill QEMU process 4. Source If final status was success and 'cont' on dest succeeded kill QEMU process else Run 'cont' in monitor In older libvirt, the bits from step 4, would actually take place at the end of step 2. This meant we could end up with no QEMU on either the source or dest, if starting CPUs on the dest QEMU failed for some reason. We would still really like to have a 'query-migrate' command for the destination, so that we can confirm that the destination has consumed all incoming migrate data successfully, rather than just blindly starting CPUs and hoping for the best. Regards, 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] [Qemu-devel] qemu and qemu.git -> Migration + disk stress introduces qcow2 corruptions
On 11/10/2011 12:42 PM, Daniel P. Berrange wrote: On Thu, Nov 10, 2011 at 12:27:30PM -0600, Anthony Liguori wrote: What does libvirt actually do in the monitor prior to migration completing on the destination? The least invasive way of doing delayed open of block devices is probably to make -incoming create a monitor and run a main loop before the block devices (and full device model) is initialized. Since this isolates the changes strictly to migration, I'd feel okay doing this for 1.0 (although it might need to be in the stable branch). The way migration works with libvirt wrt QEMU interactions is now as follows 1. Destination. Run qemu -incoming ...args... Query chardevs via monitor Query vCPU threads via monitor Set disk / vnc passwords Since RHEL carries Juan's patch, and Juan's patch doesn't handle disk passwords gracefully, how does libvirt cope with that? Regards, Anthony Liguori Set netdev link states Set balloon target 2. Source Set migration speed Set migration max downtime Run migrate command (detached) while 1 Query migration status if status is failed or success break; 3. Destination If final status was success Run 'cont' in monitor else kill QEMU process 4. Source If final status was success and 'cont' on dest succeeded kill QEMU process else Run 'cont' in monitor In older libvirt, the bits from step 4, would actually take place at the end of step 2. This meant we could end up with no QEMU on either the source or dest, if starting CPUs on the dest QEMU failed for some reason. We would still really like to have a 'query-migrate' command for the destination, so that we can confirm that the destination has consumed all incoming migrate data successfully, rather than just blindly starting CPUs and hoping for the best. Regards, Daniel -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] Wiki spam!
The wiki's been spammed, see November 9 for example: http://wiki.libvirt.org/page/Special:Recentchanges virt-manager.org had a similar problem. Any one know any good proactive ways to prevent this? - Cole -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [Qemu-devel] qemu and qemu.git -> Migration + disk stress introduces qcow2 corruptions
On 11/10/2011 02:06 PM, Daniel P. Berrange wrote: On Thu, Nov 10, 2011 at 01:11:42PM -0600, Anthony Liguori wrote: On 11/10/2011 12:42 PM, Daniel P. Berrange wrote: On Thu, Nov 10, 2011 at 12:27:30PM -0600, Anthony Liguori wrote: What does libvirt actually do in the monitor prior to migration completing on the destination? The least invasive way of doing delayed open of block devices is probably to make -incoming create a monitor and run a main loop before the block devices (and full device model) is initialized. Since this isolates the changes strictly to migration, I'd feel okay doing this for 1.0 (although it might need to be in the stable branch). The way migration works with libvirt wrt QEMU interactions is now as follows 1. Destination. Run qemu -incoming ...args... Query chardevs via monitor Query vCPU threads via monitor Set disk / vnc passwords Since RHEL carries Juan's patch, and Juan's patch doesn't handle disk passwords gracefully, how does libvirt cope with that? No idea, that's the first I've heard of any patch that causes problems with passwords in QEMU. My guess is that migration with a password protected qcow2 file isn't a common test-case. Regards, Anthony Liguori Daniel -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [Qemu-devel] qemu and qemu.git -> Migration + disk stress introduces qcow2 corruptions
On Thu, Nov 10, 2011 at 01:11:42PM -0600, Anthony Liguori wrote: > On 11/10/2011 12:42 PM, Daniel P. Berrange wrote: > >On Thu, Nov 10, 2011 at 12:27:30PM -0600, Anthony Liguori wrote: > >>What does libvirt actually do in the monitor prior to migration > >>completing on the destination? The least invasive way of doing > >>delayed open of block devices is probably to make -incoming create a > >>monitor and run a main loop before the block devices (and full > >>device model) is initialized. Since this isolates the changes > >>strictly to migration, I'd feel okay doing this for 1.0 (although it > >>might need to be in the stable branch). > > > >The way migration works with libvirt wrt QEMU interactions is now > >as follows > > > > 1. Destination. > >Run qemu -incoming ...args... > >Query chardevs via monitor > >Query vCPU threads via monitor > >Set disk / vnc passwords > > Since RHEL carries Juan's patch, and Juan's patch doesn't handle > disk passwords gracefully, how does libvirt cope with that? No idea, that's the first I've heard of any patch that causes problems with passwords in QEMU. 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] Wiki spam!
On Thu, Nov 10, 2011 at 02:50:30PM -0500, Cole Robinson wrote: > The wiki's been spammed, see November 9 for example: > > http://wiki.libvirt.org/page/Special:Recentchanges > > virt-manager.org had a similar problem. Any one know any good proactive > ways to prevent this? I have enabled a captcha for all account creation pages, and for any edit which inserts a URL. I will also be enabling mandatory email address confirmation for all accounts. 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] [PATCH 3/8] Implement virDomain{Set, Get}BlockIoTune for the qemu driver
On Thu, Nov 10, 2011 at 04:32:53AM +0800, Lei HH Li wrote: > This patch implement the blk io throttle setting and getting support to qemu > driver. > > > Signed-off-by: Zhi Yong Wu > Signed-off-by: Lei Li > --- > src/qemu/qemu_driver.c | 216 > ++ > src/qemu/qemu_monitor.c | 36 +++ > src/qemu/qemu_monitor.h | 10 ++ > src/qemu/qemu_monitor_json.c | 191 + > src/qemu/qemu_monitor_json.h | 10 ++ > src/qemu/qemu_monitor_text.c | 152 + > src/qemu/qemu_monitor_text.h | 10 ++ > 7 files changed, 625 insertions(+), 0 deletions(-) > > diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c > index db2ac0d..7ca6719 100644 > --- a/src/qemu/qemu_driver.c > +++ b/src/qemu/qemu_driver.c > @@ -10759,6 +10759,220 @@ cleanup: > return ret; > } > > +static int > +qemuDomainSetBlockIoTune(virDomainPtr dom, > + const char *disk, > + virDomainBlockIoTuneInfoPtr info, > + unsigned int flags) > +{ > +struct qemud_driver *driver = dom->conn->privateData; > +virDomainObjPtr vm = NULL; > +qemuDomainObjPrivatePtr priv; > +virDomainDefPtr persistentDef = NULL; > +char uuidstr[VIR_UUID_STRING_BUFLEN]; > +const char *device = NULL; > +int ret = -1; > +bool isActive; > + > +virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | > + VIR_DOMAIN_AFFECT_CONFIG, -1); > + > +qemuDriverLock(driver); > +virUUIDFormat(dom->uuid, uuidstr); > +vm = virDomainFindByUUID(&driver->domains, dom->uuid); > +if (!vm) { > +qemuReportError(VIR_ERR_NO_DOMAIN, > +_("no domain with matching uuid '%s'"), uuidstr); > +goto cleanup; > +} > + > +device = qemuDiskPathToAlias(vm, disk); > +if (!device) { > +goto cleanup; > +} > + > +if (qemuDomainObjBeginJobWithDriver(driver, vm, QEMU_JOB_MODIFY) < 0) > +goto cleanup; > + > +isActive = virDomainObjIsActive(vm); > + > +if (flags == VIR_DOMAIN_AFFECT_CURRENT) { > +if (isActive) > +flags = VIR_DOMAIN_AFFECT_LIVE; > +else > +flags = VIR_DOMAIN_AFFECT_CONFIG; > +} > + > +if ((info->total_bytes_sec && info->read_bytes_sec) || > +(info->total_bytes_sec && info->write_bytes_sec)) { > +qemuReportError(VIR_ERR_OPERATION_INVALID, "%s", > +_("bps and bps_rd/bps_wr cannot be used at the same > time")); These messages should use the user visible names for the fields (ie. read_bytes_sec). > +goto endjob; > +} > + > +if ((info->total_iops_sec && info->read_iops_sec) || > +(info->total_iops_sec && info->write_iops_sec)) { > +qemuReportError(VIR_ERR_OPERATION_INVALID, "%s", > +_("iops and iops_rd/iops_wr cannot be used at the > same time")); Same here. > +goto endjob; > +} > + > +if (!isActive && (flags & VIR_DOMAIN_AFFECT_LIVE)) { > +qemuReportError(VIR_ERR_OPERATION_INVALID, "%s", > +_("domain is not running")); > +goto endjob; > +} > + > + if (flags & VIR_DOMAIN_AFFECT_CONFIG) { > +if (!vm->persistent) { > +qemuReportError(VIR_ERR_OPERATION_INVALID, "%s", > +_("cannot change persistent config of a > transient domain")); > +goto endjob; > +} > +if (!(persistentDef = virDomainObjGetPersistentDef(driver->caps, > vm))) > +goto endjob; > +} > + > +if (flags & VIR_DOMAIN_AFFECT_LIVE) { > +priv = vm->privateData; > +qemuDomainObjEnterMonitorWithDriver(driver, vm); > +ret = qemuMonitorSetBlockIoThrottle(priv->mon, device, info, 1); > +qemuDomainObjExitMonitorWithDriver(driver, vm); > +} > + > +if (flags & VIR_DOMAIN_AFFECT_CONFIG) { > +sa_assert(persistentDef); > +int i = virDomainDiskIndexByName(vm->def, disk, true); > +if (i < 0) > +goto endjob; > +persistentDef->disks[i]->blkdeviotune.total_bytes_sec = > info->total_bytes_sec; > +persistentDef->disks[i]->blkdeviotune.read_bytes_sec = > info->read_bytes_sec; > +persistentDef->disks[i]->blkdeviotune.write_bytes_sec = > info->write_bytes_sec; > +persistentDef->disks[i]->blkdeviotune.total_iops_sec = > info->total_iops_sec; > +persistentDef->disks[i]->blkdeviotune.read_iops_sec = > info->read_iops_sec; > +persistentDef->disks[i]->blkdeviotune.write_iops_sec = > info->write_iops_sec; > +persistentDef->disks[i]->blkdeviotune.mark = 1; > +} > + > +if (flags & VIR_DOMAIN_AFFECT_CONFIG) { > +ret = virDomainSaveConfig(driver->configDir, persistentDef); > +if (ret < 0) { > +qemuReportError(VIR_ERR_OPERATION_INVALID, "%s", > + _("Write t
Re: [libvirt] [PATCH 4/8] Support block I/O throtte in XML
This looks good to me. On Thu, Nov 10, 2011 at 04:32:54AM +0800, Lei HH Li wrote: > Enable block I/O throttle for per-disk in XML. > > Signed-off-by: Zhi Yong Wu > Signed-off-by: Lei Li > --- > src/conf/domain_conf.c | 101 +- > src/conf/domain_conf.h | 12 ++ > src/qemu/qemu_command.c | 33 +++ > src/util/xml.h |2 + > 4 files changed, 145 insertions(+), 3 deletions(-) > > diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c > index 58f4d0f..564914e 100644 > --- a/src/conf/domain_conf.c > +++ b/src/conf/domain_conf.c > @@ -2318,7 +2318,8 @@ static virDomainDiskDefPtr > virDomainDiskDefParseXML(virCapsPtr caps, > xmlNodePtr node, > virBitmapPtr bootMap, > - unsigned int flags) > + unsigned int flags, > + xmlXPathContextPtr ctxt) > { > virDomainDiskDefPtr def; > xmlNodePtr cur, child; > @@ -2517,6 +2518,62 @@ virDomainDiskDefParseXML(virCapsPtr caps, > } > child = child->next; > } > +} else if (xmlStrEqual(cur->name, BAD_CAST "iotune")) { > +if > (virXPathULongLong("string(./devices/disk/iotune/total_bytes_sec)", > + ctxt, > &def->blkdeviotune.total_bytes_sec) < 0) { > +def->blkdeviotune.total_bytes_sec = 0; > +} else { > +def->blkdeviotune.mark = 1; > +} > + > +if > (virXPathULongLong("string(./devices/disk/iotune/read_bytes_sec)", > + ctxt, > &def->blkdeviotune.read_bytes_sec) < 0) { > +def->blkdeviotune.read_bytes_sec = 0; > +} else { > +def->blkdeviotune.mark = 1; > +} > + > +if > (virXPathULongLong("string(./devices/disk/iotune/write_bytes_sec)", > + ctxt, > &def->blkdeviotune.write_bytes_sec) < 0) { > +def->blkdeviotune.write_bytes_sec = 0; > +} else { > +def->blkdeviotune.mark = 1; > +} > + > + if > (virXPathULongLong("string(./devices/disk/iotune/total_iops_sec)", > + ctxt, > &def->blkdeviotune.total_iops_sec) < 0) { > +def->blkdeviotune.total_iops_sec = 0; > +} else { > +def->blkdeviotune.mark = 1; > +} > + > +if > (virXPathULongLong("string(./devices/disk/iotune/read_iops_sec)", > + ctxt, > &def->blkdeviotune.read_iops_sec) < 0) { > +def->blkdeviotune.read_iops_sec = 0; > +} else { > +def->blkdeviotune.mark = 1; > +} > + > +if > (virXPathULongLong("string(./devices/disk/iotune/write_iops_sec)", > + ctxt, > &def->blkdeviotune.write_iops_sec) < 0) { > +def->blkdeviotune.write_iops_sec = 0; > +} else { > +def->blkdeviotune.mark = 1; > +} > + > +if ((def->blkdeviotune.total_bytes_sec && > def->blkdeviotune.read_bytes_sec) > +|| (def->blkdeviotune.total_bytes_sec && > def->blkdeviotune.write_bytes_sec)) { > +virDomainReportError(VIR_ERR_XML_ERROR, > + _("bps and bps_rd/bps_wr cannot be > set at the same time")); > +goto error; > +} > + > +if ((def->blkdeviotune.total_iops_sec && > def->blkdeviotune.read_iops_sec) > +|| (def->blkdeviotune.total_iops_sec && > def->blkdeviotune.write_iops_sec)) { > +virDomainReportError(VIR_ERR_XML_ERROR, > + _("iops and iops_rd/iops_wr cannot > be set at the same time")); > +goto error; > +} > } else if (xmlStrEqual(cur->name, BAD_CAST "readonly")) { > def->readonly = 1; > } else if (xmlStrEqual(cur->name, BAD_CAST "shareable")) { > @@ -6003,7 +6060,7 @@ virDomainDeviceDefPtr > virDomainDeviceDefParse(virCapsPtr caps, > if (xmlStrEqual(node->name, BAD_CAST "disk")) { > dev->type = VIR_DOMAIN_DEVICE_DISK; > if (!(dev->data.disk = virDomainDiskDefParseXML(caps, node, > -NULL, flags))) > +NULL, flags, NULL))) > goto error; > } else if (xmlStrEqual(node->name, BAD_CAST "lease")) { > dev->type = VIR_DOMAIN_DEVICE_LEASE; > @@ -7076,7 +7133,8 @@ static virDomainD
[libvirt] [libvirt PATCHv5 1/2] add DHCP snooping
This patch adds DHCP Snooping support to libvirt. Signed-off-by: David L Stevens --- docs/formatnwfilter.html.in | 17 + examples/xml/nwfilter/no-ip-spoofing.xml |5 + src/Makefile.am |2 + src/nwfilter/nwfilter_dhcpsnoop.c| 745 ++ src/nwfilter/nwfilter_dhcpsnoop.h| 38 ++ src/nwfilter/nwfilter_driver.c |6 + src/nwfilter/nwfilter_gentech_driver.c | 53 ++- 7 files changed, 853 insertions(+), 13 deletions(-) create mode 100644 src/nwfilter/nwfilter_dhcpsnoop.c create mode 100644 src/nwfilter/nwfilter_dhcpsnoop.h diff --git a/docs/formatnwfilter.html.in b/docs/formatnwfilter.html.in index 8df4a93..8003320 100644 --- a/docs/formatnwfilter.html.in +++ b/docs/formatnwfilter.html.in @@ -1775,6 +1775,23 @@ In case a VM is resumed after suspension or migrated, IP address detection will be restarted. + + Variable ip_learning may be used to specify + the IP address learning method. Valid values are any, dhcp, + or none. The default value is any, meaning that libvirt + may use any packet to determine the address in use by a VM. A value of + dhcp specifies that libvirt should only honor DHCP server-assigned + addresses with valid leases. If ip_learning is set to none, + libvirt does not do address learning and referencing IP without + assigning it an explicit value is an error. + + Use of ip_learning=dhcp (DHCP snooping) provides additional + anti-spoofing security, especially when combined with a filter allowing + only trusted DHCP servers to assign addresses. If the DHCP lease expires, + the VM will no longer be able to use the IP address until it acquires a + new, valid lease from a DHCP server. If the VM is migrated, it must get + a new valid DHCP lease to use an IP address (e.g., by + bringing the VM interface down and up again). VM Migration diff --git a/examples/xml/nwfilter/no-ip-spoofing.xml b/examples/xml/nwfilter/no-ip-spoofing.xml index b8c94c8..7c7fd46 100644 --- a/examples/xml/nwfilter/no-ip-spoofing.xml +++ b/examples/xml/nwfilter/no-ip-spoofing.xml @@ -1,5 +1,10 @@ + + + + diff --git a/src/Makefile.am b/src/Makefile.am index 87d91ed..c948cbf 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -481,6 +481,8 @@ NWFILTER_DRIVER_SOURCES = \ nwfilter/nwfilter_driver.h nwfilter/nwfilter_driver.c \ nwfilter/nwfilter_gentech_driver.c \ nwfilter/nwfilter_gentech_driver.h \ + nwfilter/nwfilter_dhcpsnoop.c \ + nwfilter/nwfilter_dhcpsnoop.h \ nwfilter/nwfilter_ebiptables_driver.c \ nwfilter/nwfilter_ebiptables_driver.h \ nwfilter/nwfilter_learnipaddr.c \ diff --git a/src/nwfilter/nwfilter_dhcpsnoop.c b/src/nwfilter/nwfilter_dhcpsnoop.c new file mode 100644 index 000..8a37a6f --- /dev/null +++ b/src/nwfilter/nwfilter_dhcpsnoop.c @@ -0,0 +1,745 @@ +/* + * nwfilter_dhcpsnoop.c: support for DHCP snooping used by a VM + * on an interface + * + * Copyright (C) 2011 IBM Corp. + * Copyright (C) 2011 David L Stevens + * + * 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: David L Stevens + * Based in part on work by Stefan Berger + */ + +#include + +#ifdef HAVE_LIBPCAP +#include +#endif + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "internal.h" + +#include "buf.h" +#include "memory.h" +#include "logging.h" +#include "datatypes.h" +#include "interface.h" +#include "virterror_internal.h" +#include "threads.h" +#include "conf/nwfilter_params.h" +#include "conf/domain_conf.h" +#include "nwfilter_gentech_driver.h" +#include "nwfilter_ebiptables_driver.h" +#include "nwfilter_dhcpsnoop.h" + +#define VIR_FROM_THIS VIR_FROM_NWFILTER + +#ifdef HAVE_LIBPCAP + +static virHashTablePtr SnoopReqs; +static pthr
Re: [libvirt] Wiki spam!
On 11/10/2011 03:10 PM, Daniel P. Berrange wrote: > On Thu, Nov 10, 2011 at 02:50:30PM -0500, Cole Robinson wrote: >> The wiki's been spammed, see November 9 for example: >> >> http://wiki.libvirt.org/page/Special:Recentchanges >> >> virt-manager.org had a similar problem. Any one know any good proactive >> ways to prevent this? > > I have enabled a captcha for all account creation pages, and for any > edit which inserts a URL. > > I will also be enabling mandatory email address confirmation for all > accounts. > Hmm, I thought et.redhat.com couldn't send email? Do those changes affect virt-manager.org as well? - Cole -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt PATCHv5 0/2] add DHCP Snooping support for libvirt
These patches add DHCP snooping support to libvirt. The learning method for IP addresses is specified by setting the "ip_learning" variable to one of "any" [default] (existing IP learning code), "none" (static only addresses) or "dhcp" (DHCP snooping). Differences from v4: - added documentation of "ip_learning" - added support for kill -HUP reloading - simplified lease file handling David L Stevens (2): add DHCP snooping add leasefile support docs/formatnwfilter.html.in | 17 + examples/xml/nwfilter/no-ip-spoofing.xml |5 + src/Makefile.am |2 + src/nwfilter/nwfilter_dhcpsnoop.c| 961 ++ src/nwfilter/nwfilter_dhcpsnoop.h| 38 ++ src/nwfilter/nwfilter_driver.c |6 + src/nwfilter/nwfilter_gentech_driver.c | 53 ++- 7 files changed, 1069 insertions(+), 13 deletions(-) create mode 100644 src/nwfilter/nwfilter_dhcpsnoop.c create mode 100644 src/nwfilter/nwfilter_dhcpsnoop.h -- 1.7.6.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt PATCHv5 2/2] add leasefile support
This patch adds support for saving DHCP snooping leases to an on-disk file and restoring saved leases that are still active on restart. Signed-off-by: David L Stevens --- src/nwfilter/nwfilter_dhcpsnoop.c | 270 + 1 files changed, 243 insertions(+), 27 deletions(-) diff --git a/src/nwfilter/nwfilter_dhcpsnoop.c b/src/nwfilter/nwfilter_dhcpsnoop.c index 8a37a6f..918ad7b 100644 --- a/src/nwfilter/nwfilter_dhcpsnoop.c +++ b/src/nwfilter/nwfilter_dhcpsnoop.c @@ -55,10 +55,18 @@ #include "nwfilter_gentech_driver.h" #include "nwfilter_ebiptables_driver.h" #include "nwfilter_dhcpsnoop.h" +#include "virfile.h" +#include "configmake.h" #define VIR_FROM_THIS VIR_FROM_NWFILTER #ifdef HAVE_LIBPCAP + +#define LEASEFILE LOCALSTATEDIR "/run/libvirt/network/nwfilter.leases" +#define TMPLEASEFILE LOCALSTATEDIR "/run/libvirt/network/nwfilter.ltmp" +static int lease_fd = -1; +static int nleases = 0; /* number of active leases */ +static int wleases = 0; /* number of written leases */ static virHashTablePtr SnoopReqs; static pthread_mutex_t SnoopLock; @@ -76,6 +84,7 @@ struct virNWFilterSnoopReq { const char *filtername; virNWFilterHashTablePtr vars; virNWFilterDriverStatePtr driver; +bool running; /* start and end of lease list, ordered by lease time */ struct iplease *start; struct iplease *end; @@ -96,7 +105,15 @@ struct iplease { static struct iplease *ipl_getbyip(struct iplease *start, uint32_t ipaddr); static void ipl_update(struct iplease *pl, uint32_t timeout); + +static struct virNWFilterSnoopReq *newreq(const char *ifname); +static void lease_open(void); +static void lease_close(void); +static void lease_load(void); +static void lease_save(struct iplease *ipl); +static void lease_restore(struct virNWFilterSnoopReq *req); +static void lease_refresh(void); /* * ipl_ladd - add an IP lease to a list @@ -187,7 +204,7 @@ ipl_install(struct iplease *ipl) * ipl_add - create or update an IP lease */ static void -ipl_add(struct iplease *plnew) +ipl_add(struct iplease *plnew, bool update_leasefile) { struct iplease *pl; struct virNWFilterSnoopReq *req = plnew->ipl_req; @@ -195,6 +212,8 @@ ipl_add(struct iplease *plnew) pl = ipl_getbyip(req->start, plnew->ipl_ipaddr); if (pl) { ipl_update(pl, plnew->ipl_timeout); +if (update_leasefile) +lease_save(pl); return; } /* support for multiple addresses requires the ability to add filters @@ -212,11 +231,14 @@ ipl_add(struct iplease *plnew) } *pl = *plnew; -if (ipl_install(pl) < 0) { +if (req->running && ipl_install(pl) < 0) { VIR_FREE(pl); return; } ipl_tadd(pl); +nleases++; +if (update_leasefile) +lease_save(pl); } /* @@ -252,7 +274,7 @@ ipl_tdel(struct iplease *ipl) * ipl_del - delete an IP lease */ static void -ipl_del(struct virNWFilterSnoopReq *req, uint32_t ipaddr) +ipl_del(struct virNWFilterSnoopReq *req, uint32_t ipaddr, bool update_leasefile) { struct iplease *ipl; @@ -262,13 +284,18 @@ ipl_del(struct virNWFilterSnoopReq *req, uint32_t ipaddr) ipl_tdel(ipl); -/* for multiple address support, this needs to remove those rules - * referencing "IP" with ipl's ip value. - */ -if (req->techdriver->applyDHCPOnlyRules(req->ifname, req->macaddr, NULL)) { -virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "ipl_ldel failed"); +if (update_leasefile) { +lease_save(ipl); + +/* + * for multiple address support, this needs to remove those rules + * referencing "IP" with ipl's ip value. + */ +if (req->techdriver->applyDHCPOnlyRules(req->ifname,req->macaddr,NULL)) +virNWFilterReportError(VIR_ERR_INTERNAL_ERROR, "ipl_ldel failed"); } VIR_FREE(ipl); +nleases--; } /* @@ -308,7 +335,7 @@ ipl_trun(struct virNWFilterSnoopReq *req) now = time(0); while (req->start && req->start->ipl_timeout <= now) -ipl_del(req, req->start->ipl_ipaddr); +ipl_del(req, req->start->ipl_ipaddr, 1); return 0; } @@ -467,11 +494,11 @@ dhcpdecode(struct virNWFilterSnoopReq *req, struct eth *pep, int len) switch (mtype) { case DHCPACK: -ipl_add(&ipl); +ipl_add(&ipl, 1); break; case DHCPDECLINE: case DHCPRELEASE: -ipl_del(req, ipl.ipl_ipaddr); +ipl_del(req, ipl.ipl_ipaddr, 1); break; default: break; @@ -521,7 +548,7 @@ snoopReqFree(struct virNWFilterSnoopReq *req) /* free all leases */ snoop_lock(); for (ipl = req->start; ipl; ipl = req->start) -ipl_del(req, ipl->ipl_ipaddr); +ipl_del(req, ipl->ipl_ipaddr, 0); snoop_unlock(); /* free all req data */ @@ -547,6 +574,8 @@ virNWFilterDHCPSnoop(void
[libvirt] [libvirt-glib 02/37] Use new helpers to simplify gvir_config_domain_set_features
--- libvirt-gconfig/libvirt-gconfig-domain.c | 17 +++-- 1 files changed, 3 insertions(+), 14 deletions(-) diff --git a/libvirt-gconfig/libvirt-gconfig-domain.c b/libvirt-gconfig/libvirt-gconfig-domain.c index 3290389..c847c14 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain.c +++ b/libvirt-gconfig/libvirt-gconfig-domain.c @@ -223,27 +223,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_new_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"); } -- 1.7.7 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-glib 21/37] Add gvir_config_domain_set_devices
--- libvirt-gconfig/libvirt-gconfig-domain.c | 21 + libvirt-gconfig/libvirt-gconfig-domain.h |2 ++ libvirt-gconfig/libvirt-gconfig.sym |3 ++- 3 files changed, 25 insertions(+), 1 deletions(-) diff --git a/libvirt-gconfig/libvirt-gconfig-domain.c b/libvirt-gconfig/libvirt-gconfig-domain.c index 88b46fb..8f6c50f 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain.c +++ b/libvirt-gconfig/libvirt-gconfig-domain.c @@ -283,3 +283,24 @@ 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; + +devices_node = gvir_config_object_new_child(GVIR_CONFIG_OBJECT(domain), +"devices", TRUE); +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 76ffc4c..963ca53 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 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-glib 15/37] 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 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-glib 29/37] Add GVirConfigDeviceInput
--- libvirt-gconfig/Makefile.am|2 + libvirt-gconfig/libvirt-gconfig-device-input.c | 109 libvirt-gconfig/libvirt-gconfig-device-input.h | 76 libvirt-gconfig/libvirt-gconfig.h |1 + libvirt-gconfig/libvirt-gconfig.sym|7 ++ libvirt-gconfig/tests/test-domain-create.c | 15 +++- 6 files changed, 207 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 c74d123..dcb5caa 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 \ @@ -35,6 +36,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..a1ae1b1 --- /dev/null +++ b/libvirt-gconfig/libvirt-gconfig-device-input.c @@ -0,0 +1,109 @@ +/* + * 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 + */ + +#include + +#include + +#include + +#include "libvirt-gconfig/libvirt-gconfig.h" +#include "libvirt-gconfig/libvirt-gconfig-helpers-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; + +node = gvir_config_object_get_xml_node(GVIR_CONFIG_OBJECT(input)); +if (node == NULL) +return; +type_str = gvir_config_genum_get_nick(GVIR_TYPE_CONFIG_DEVICE_INPUT_DEVICE_TYPE, + type); +if (type_str
[libvirt] [libvirt-glib 06/37] 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. --- configure.ac |4 ++ libvirt-gconfig/Makefile.am| 21 +++- .../libvirt-gconfig-enum-types.c.template | 36 .../libvirt-gconfig-enum-types.h.template | 24 + libvirt-gconfig/libvirt-gconfig.h |1 + 5 files changed, 85 insertions(+), 1 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 3fd268a..a0dec08 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 @@ -28,6 +31,8 @@ GCONFIG_SOURCE_FILES = \ libvirt-gconfig-clock.c \ libvirt-gconfig-domain.c \ libvirt-gconfig-domain-snapshot.c \ + libvirt-gconfig-enum-types.c \ + libvirt-gconfig-enum-types.h \ libvirt-gconfig-helpers.c \ libvirt-gconfig-interface.c \ libvirt-gconfig-network.c \ @@ -64,6 +69,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 + +/*** 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 (g_intern_static_string ("@EnumName@"), values); + g_once_init_leave (&g_define_type_id__volatile, g_define_type_id); +} + + return g_define_type_id__volatile; +} + +/*** END value-tail ***/ diff --git a/libvirt-gconfig/libvirt-gconfig-enum-types.h.template b/libvirt-gconfig/libvirt-gconfig-enum-types.h.template new file mode 100644 index 000..2cab1c5 --- /dev/null +++ b/libvirt-gconfig/libvirt-gconfig-enum-types.h.template @@ -0,0 +1,24 @@ +/*** BEGIN file-header ***/ +#ifndef __LIBVIRT
[libvirt] [libvirt-glib 03/37] Add gobject boilerplate for GVirConfigClock and GVirConfigTimer
--- libvirt-gconfig/Makefile.am |4 ++ libvirt-gconfig/libvirt-gconfig-clock.c | 82 +++ libvirt-gconfig/libvirt-gconfig-clock.h | 68 + libvirt-gconfig/libvirt-gconfig-timer.c | 82 +++ libvirt-gconfig/libvirt-gconfig-timer.h | 68 + libvirt-gconfig/libvirt-gconfig.h |2 + libvirt-gconfig/libvirt-gconfig.sym |8 +++ 7 files changed, 314 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 0d15e78..3fd268a 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 = \ @@ -23,6 +25,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 \ @@ -31,6 +34,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..d2650ad --- /dev/null +++ b/libvirt-gconfig/libvirt-gconfig-clock.c @@ -0,0 +1,82 @@ +/* + * 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 + */ + +#include + +#include + +#include + +#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 = gvir_config_object_new_from_xml(GVIR_TYPE_CON
[libvirt] [libvirt-glib 23/37] 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 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-glib 13/37] Add gvir_config_os_set_{machine, arch}
--- libvirt-gconfig/libvirt-gconfig-os.c | 32 libvirt-gconfig/libvirt-gconfig-os.h |2 ++ libvirt-gconfig/libvirt-gconfig.sym |2 ++ 3 files changed, 36 insertions(+), 0 deletions(-) diff --git a/libvirt-gconfig/libvirt-gconfig-os.c b/libvirt-gconfig/libvirt-gconfig-os.c index cfe827e..3e23493 100644 --- a/libvirt-gconfig/libvirt-gconfig-os.c +++ b/libvirt-gconfig/libvirt-gconfig-os.c @@ -177,3 +177,35 @@ void gvir_config_os_set_boot_devices(GVirConfigOs *os, GList *boot_devices) } } } + +void gvir_config_os_set_arch(GVirConfigOs *os, const char *arch) +{ +xmlNodePtr os_node; +xmlNodePtr os_type_node; + +os_node = gvir_config_object_get_xml_node(GVIR_CONFIG_OBJECT(os)); +if (os_node == NULL) +return; + +os_type_node = gvir_config_xml_get_element(os_node, "type", NULL); +if (os_type_node == NULL) +return; + +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; + +os_node = gvir_config_object_get_xml_node(GVIR_CONFIG_OBJECT(os)); +if (os_node == NULL) +return; + +os_type_node = gvir_config_xml_get_element(os_node, "type", NULL); +if (os_type_node == NULL) +return; + +xmlNewProp(os_type_node, (xmlChar*)"machine", (xmlChar*)machine); +} diff --git a/libvirt-gconfig/libvirt-gconfig-os.h b/libvirt-gconfig/libvirt-gconfig-os.h index 87027da..b789eb3 100644 --- a/libvirt-gconfig/libvirt-gconfig-os.h +++ b/libvirt-gconfig/libvirt-gconfig-os.h @@ -80,8 +80,10 @@ GVirConfigOs *gvir_config_os_new(void); GVirConfigOs *gvir_config_os_new_from_xml(const gchar *xml, GError **error); void gvir_config_os_set_os_type(GVirConfigOs *os, GVirConfigOsType type); +void gvir_config_os_set_arch(GVirConfigOs *os, const char *arch); void gvir_config_os_set_boot_devices(GVirConfigOs *os, GList *boot_devices); void gvir_config_os_set_loader(GVirConfigOs *os, const char * loader); +void gvir_config_os_set_machine(GVirConfigOs *os, const char *machine); void gvir_config_os_set_smbios_mode(GVirConfigOs *os, GVirConfigOsSmBiosMode mode); void gvir_config_os_enable_boot_menu(GVirConfigOs *os, gboolean enable); diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym index 3466129..20b0150 100644 --- a/libvirt-gconfig/libvirt-gconfig.sym +++ b/libvirt-gconfig/libvirt-gconfig.sym @@ -63,6 +63,8 @@ LIBVIRT_GOBJECT_0.0.1 { gvir_config_os_set_smbios_mode; gvir_config_os_enable_boot_menu; gvir_config_os_bios_enable_serial; + gvir_config_os_set_machine; + gvir_config_os_set_arch; gvir_config_secret_get_type; gvir_config_secret_new; -- 1.7.7 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-glib 01/37] Add gvir_config_object_new_child helper
This allows us to factor the code to add an XML node to a config object. --- libvirt-gconfig/libvirt-gconfig-object.c | 72 ++ libvirt-gconfig/libvirt-gconfig-object.h |4 ++ libvirt-gconfig/libvirt-gconfig.h|2 +- 3 files changed, 49 insertions(+), 29 deletions(-) diff --git a/libvirt-gconfig/libvirt-gconfig-object.c b/libvirt-gconfig/libvirt-gconfig-object.c index fbdbedd..598ac0c 100644 --- a/libvirt-gconfig/libvirt-gconfig-object.c +++ b/libvirt-gconfig/libvirt-gconfig-object.c @@ -294,35 +294,62 @@ char *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? - */ -void gvir_config_object_set_node_content(GVirConfigObject *object, - const char *node_name, - const char *value) +void +gvir_config_object_set_child(GVirConfigObject *object, xmlNodePtr child) { 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_if_fail (parent_node != 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); +old_node = xmlReplaceNode(old_node, child); xmlFreeNode(old_node); } else { -xmlAddChild(parent_node, new_node); +xmlAddChild(parent_node, child); } } +xmlNodePtr +gvir_config_object_new_child(GVirConfigObject *object, const char *child_name) +{ +xmlNodePtr new_node; + +new_node = xmlNewDocNode(NULL, NULL, (xmlChar *)child_name, NULL); +gvir_config_object_set_child(object, new_node); +return new_node; +} + +void gvir_config_object_set_node_content(GVirConfigObject *object, + const char *node_name, + const char *value) +{ +xmlNodePtr node; +xmlChar *encoded_data; + +node = gvir_config_object_new_child(object, node_name); +g_return_if_fail(node != NULL); +encoded_data = xmlEncodeEntitiesReentrant(node->doc, + (xmlChar *)value); +xmlNodeSetContent(node, encoded_data); +xmlFree(encoded_data); +} + +void gvir_config_object_set_node_content_uint64(GVirConfigObject *object, +const char *node_name, +guint64 value) +{ +char *str; +str = g_strdup_printf("%"G_GUINT64_FORMAT, value); +gvir_config_object_set_node_content(object, node_name, str); +g_free(str); +} + /* FIXME: how to notify of errors/node not found? */ guint64 gvir_config_object_get_node_content_uint64(GVirConfigObject *object, const char *node_name) @@ -345,17 +372,6 @@ guint64 gvir_config_object_get_node_content_uint64(GVirConfigObject *object, return value; } - -void gvir_config_object_set_node_content_uint64(GVirConfigObject *object, -const char *node_name, -guint64 value) -{ -char *str; -str = g_strdup_printf("%"G_GUINT64_FORMAT, value); -gvir_config_object_set_node_content(object, node_name, str); -g_free(str); -} - GVirConfigObject *gvir_config_object_new_from_xml(GType type, const char *root_name, const char *schema, diff --git a/libvirt-gconfig/libvirt-gconfig-object.h b/libvirt-gconfig/libvirt-gconfig-object.h index 52e4525..8e67b92 100644 --- a/libvirt-gconfig/libvirt-gconfig-object.h +++ b/libvirt-gconfig/libvirt-gconfig-object.h @@ -78,6 +78,10 @@ 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); +xmlNodePtr gvir_config_object_new_child(GVirConfigObject *object, +const char *child_name); +void gvir_config_object_s
[libvirt] [PATCH libvirt-glib 1/3] Add GVirDomainDevice abstract class
--- libvirt-gobject/Makefile.am|3 + .../libvirt-gobject-domain-device-private.h| 31 + libvirt-gobject/libvirt-gobject-domain-device.c| 139 libvirt-gobject/libvirt-gobject-domain-device.h| 64 + libvirt-gobject/libvirt-gobject.h |1 + libvirt-gobject/libvirt-gobject.sym|2 + 6 files changed, 240 insertions(+), 0 deletions(-) create mode 100644 libvirt-gobject/libvirt-gobject-domain-device-private.h create mode 100644 libvirt-gobject/libvirt-gobject-domain-device.c create mode 100644 libvirt-gobject/libvirt-gobject-domain-device.h diff --git a/libvirt-gobject/Makefile.am b/libvirt-gobject/Makefile.am index 4f84b8b..56a047e 100644 --- a/libvirt-gobject/Makefile.am +++ b/libvirt-gobject/Makefile.am @@ -7,6 +7,7 @@ GOBJECT_HEADER_FILES = \ libvirt-gobject.h \ libvirt-gobject-main.h \ libvirt-gobject-domain-snapshot.h \ + libvirt-gobject-domain-device.h \ libvirt-gobject-domain.h \ libvirt-gobject-interface.h \ libvirt-gobject-network.h \ @@ -21,6 +22,7 @@ GOBJECT_HEADER_FILES = \ GOBJECT_SOURCE_FILES = \ libvirt-gobject-main.c \ libvirt-gobject-domain-snapshot.c \ + libvirt-gobject-domain-device.c \ libvirt-gobject-domain.c \ libvirt-gobject-interface.c \ libvirt-gobject-network.c \ @@ -42,6 +44,7 @@ libvirt_gobject_1_0_la_HEADERS = \ $(GOBJECT_HEADER_FILES) \ libvirt-gobject-input-stream.h nodist_libvirt_gobject_1_0_la_HEADERS = \ + libvirt-gobject-domain-device-private.h \ libvirt-gobject-enums.h libvirt_gobject_1_0_la_SOURCES = \ $(libvirt_gobject_1_0_la_HEADERS) \ diff --git a/libvirt-gobject/libvirt-gobject-domain-device-private.h b/libvirt-gobject/libvirt-gobject-domain-device-private.h new file mode 100644 index 000..2a34309 --- /dev/null +++ b/libvirt-gobject/libvirt-gobject-domain-device-private.h @@ -0,0 +1,31 @@ +/* + * libvirt-gobject-domain-device-private.h: 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: Marc-André Lureau + */ +#ifndef __LIBVIRT_GOBJECT_DOMAIN_DEVICE_PRIVATE_H__ +#define __LIBVIRT_GOBJECT_DOMAIN_DEVICE_PRIVATEH__ + +G_BEGIN_DECLS + +virDomainPtr gvir_domain_device_get_domain_handle(GVirDomainDevice *self); + +G_END_DECLS + +#endif /* __LIBVIRT_GOBJECT_DOMAIN_DEVICE_PRIVATEH__ */ diff --git a/libvirt-gobject/libvirt-gobject-domain-device.c b/libvirt-gobject/libvirt-gobject-domain-device.c new file mode 100644 index 000..ae03489 --- /dev/null +++ b/libvirt-gobject/libvirt-gobject-domain-device.c @@ -0,0 +1,139 @@ +/* + * libvirt-gobject-domain-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: Marc-André Lureau + */ + +#include + +#include +#include + +#include "libvirt-glib/libvirt-glib.h" +#include "libvirt-gobject/libvirt-gobject.h" + +#include "libvirt-gobject/libvirt-gobject-domain-device-private.h" + +extern gboolean debugFlag; + +#define DEBUG(fmt, ...) do { if (G_UNLIKELY(debugFlag)) g_debug(fmt, ## __VA_ARGS__); } while (0) + +#define GVIR_DOMAIN_DEVICE_GET_PRIVATE(o
[libvirt] [PATCH libvirt-glib 3/3] Add GVirDomainDisk
--- libvirt-gobject/Makefile.am |2 + libvirt-gobject/libvirt-gobject-domain-disk.c | 210 + libvirt-gobject/libvirt-gobject-domain-disk.h | 78 + libvirt-gobject/libvirt-gobject.h |1 + libvirt-gobject/libvirt-gobject.sym |4 + 5 files changed, 295 insertions(+), 0 deletions(-) create mode 100644 libvirt-gobject/libvirt-gobject-domain-disk.c create mode 100644 libvirt-gobject/libvirt-gobject-domain-disk.h diff --git a/libvirt-gobject/Makefile.am b/libvirt-gobject/Makefile.am index 8b59109..101007e 100644 --- a/libvirt-gobject/Makefile.am +++ b/libvirt-gobject/Makefile.am @@ -8,6 +8,7 @@ GOBJECT_HEADER_FILES = \ libvirt-gobject-main.h \ libvirt-gobject-domain-snapshot.h \ libvirt-gobject-domain-device.h \ + libvirt-gobject-domain-disk.h \ libvirt-gobject-domain-interface.h \ libvirt-gobject-domain.h \ libvirt-gobject-interface.h \ @@ -24,6 +25,7 @@ GOBJECT_SOURCE_FILES = \ libvirt-gobject-main.c \ libvirt-gobject-domain-snapshot.c \ libvirt-gobject-domain-device.c \ + libvirt-gobject-domain-disk.c \ libvirt-gobject-domain-interface.c \ libvirt-gobject-domain.c \ libvirt-gobject-interface.c \ diff --git a/libvirt-gobject/libvirt-gobject-domain-disk.c b/libvirt-gobject/libvirt-gobject-domain-disk.c new file mode 100644 index 000..0481967 --- /dev/null +++ b/libvirt-gobject/libvirt-gobject-domain-disk.c @@ -0,0 +1,210 @@ +/* + * libvirt-gobject-domain-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 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: Marc-André Lureau + */ + +#include + +#include +#include + +#include "libvirt-glib/libvirt-glib.h" +#include "libvirt-gobject/libvirt-gobject.h" + +#include "libvirt-gobject/libvirt-gobject-domain-device-private.h" + +extern gboolean debugFlag; + +#define DEBUG(fmt, ...) do { if (G_UNLIKELY(debugFlag)) g_debug(fmt, ## __VA_ARGS__); } while (0) + +#define GVIR_DOMAIN_DISK_GET_PRIVATE(obj) \ +(G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_TYPE_DOMAIN_DISK, GVirDomainDiskPrivate)) + +struct _GVirDomainDiskPrivate +{ +gchar *path; +}; + +G_DEFINE_TYPE(GVirDomainDisk, gvir_domain_disk, GVIR_TYPE_DOMAIN_DEVICE); + +enum { +PROP_0, +PROP_PATH, +}; + +#define GVIR_DOMAIN_DISK_ERROR gvir_domain_disk_error_quark() + + +static GQuark +gvir_domain_disk_error_quark(void) +{ +return g_quark_from_static_string("gvir-domain-disk"); +} + +static void gvir_domain_disk_get_property(GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ +GVirDomainDisk *self = GVIR_DOMAIN_DISK(object); +GVirDomainDiskPrivate *priv = self->priv; + +switch (prop_id) { +case PROP_PATH: +g_value_set_string(value, priv->path); +break; + +default: +G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); +} +} + + +static void gvir_domain_disk_set_property(GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ +GVirDomainDisk *self = GVIR_DOMAIN_DISK(object); +GVirDomainDiskPrivate *priv = self->priv; + +switch (prop_id) { +case PROP_PATH: +if (priv->path) +g_free(priv->path); +priv->path = g_value_dup_string(value); +break; + +default: +G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); +} +} + + +static void gvir_domain_disk_finalize(GObject *object) +{ +GVirDomainDisk *self = GVIR_DOMAIN_DISK(object); +GVirDomainDiskPrivate *priv = self->priv; + +DEBUG("Finalize GVirDomainDisk=%p", self); + +if (priv->path) +g_free(priv->path); + +G_OBJECT_CLASS(gvir_domain_disk_parent_class
[libvirt] [libvirt-glib 24/37] 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 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/libvirt-gconfig/libvirt-gconfig-interface.c b/libvirt-gconfig/libvirt-gconfig-interface.c index 5e934f6..5eece82 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) -- 1.7.7 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-glib 08/37] 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 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH libvirt-glib 2/3] Add GVirDomainInterface
--- libvirt-gobject/Makefile.am|2 + libvirt-gobject/libvirt-gobject-domain-interface.c | 213 libvirt-gobject/libvirt-gobject-domain-interface.h | 81 libvirt-gobject/libvirt-gobject.h |1 + libvirt-gobject/libvirt-gobject.sym|4 + 5 files changed, 301 insertions(+), 0 deletions(-) create mode 100644 libvirt-gobject/libvirt-gobject-domain-interface.c create mode 100644 libvirt-gobject/libvirt-gobject-domain-interface.h diff --git a/libvirt-gobject/Makefile.am b/libvirt-gobject/Makefile.am index 56a047e..8b59109 100644 --- a/libvirt-gobject/Makefile.am +++ b/libvirt-gobject/Makefile.am @@ -8,6 +8,7 @@ GOBJECT_HEADER_FILES = \ libvirt-gobject-main.h \ libvirt-gobject-domain-snapshot.h \ libvirt-gobject-domain-device.h \ + libvirt-gobject-domain-interface.h \ libvirt-gobject-domain.h \ libvirt-gobject-interface.h \ libvirt-gobject-network.h \ @@ -23,6 +24,7 @@ GOBJECT_SOURCE_FILES = \ libvirt-gobject-main.c \ libvirt-gobject-domain-snapshot.c \ libvirt-gobject-domain-device.c \ + libvirt-gobject-domain-interface.c \ libvirt-gobject-domain.c \ libvirt-gobject-interface.c \ libvirt-gobject-network.c \ diff --git a/libvirt-gobject/libvirt-gobject-domain-interface.c b/libvirt-gobject/libvirt-gobject-domain-interface.c new file mode 100644 index 000..65a5467 --- /dev/null +++ b/libvirt-gobject/libvirt-gobject-domain-interface.c @@ -0,0 +1,213 @@ +/* + * libvirt-gobject-domain-interface.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: Marc-André Lureau + */ + +#include + +#include +#include + +#include "libvirt-glib/libvirt-glib.h" +#include "libvirt-gobject/libvirt-gobject.h" + +#include "libvirt-gobject/libvirt-gobject-domain-device-private.h" + +extern gboolean debugFlag; + +#define DEBUG(fmt, ...) do { if (G_UNLIKELY(debugFlag)) g_debug(fmt, ## __VA_ARGS__); } while (0) + +#define GVIR_DOMAIN_INTERFACE_GET_PRIVATE(obj) \ +(G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_TYPE_DOMAIN_INTERFACE, GVirDomainInterfacePrivate)) + +struct _GVirDomainInterfacePrivate +{ +gchar *path; +}; + +G_DEFINE_TYPE(GVirDomainInterface, gvir_domain_interface, GVIR_TYPE_DOMAIN_DEVICE); + +enum { +PROP_0, +PROP_PATH, +}; + +#define GVIR_DOMAIN_INTERFACE_ERROR gvir_domain_interface_error_quark() + + +static GQuark +gvir_domain_interface_error_quark(void) +{ +return g_quark_from_static_string("gvir-domain-interface"); +} + +static void gvir_domain_interface_get_property(GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ +GVirDomainInterface *self = GVIR_DOMAIN_INTERFACE(object); +GVirDomainInterfacePrivate *priv = self->priv; + +switch (prop_id) { +case PROP_PATH: +g_value_set_string(value, priv->path); +break; + +default: +G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); +} +} + + +static void gvir_domain_interface_set_property(GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ +GVirDomainInterface *self = GVIR_DOMAIN_INTERFACE(object); +GVirDomainInterfacePrivate *priv = self->priv; + +switch (prop_id) { +case PROP_PATH: +if (priv->path) +g_free(priv->path); +priv->path = g_value_dup_string(value); +break; + +default: +G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); +} +} + + +static void gvir_domain_interface_finalize(GObject *object) +{ +GVirDomainInterface *self = GVIR_DOMAIN_INTERFACE(object); +GVirDomainInterfacePrivate *priv
[libvirt] [libvirt-glib 10/37] 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. --- libvirt-gconfig/libvirt-gconfig-clock.c | 15 ++- libvirt-gconfig/libvirt-gconfig-helpers-private.h |1 + libvirt-gconfig/libvirt-gconfig-helpers.c | 17 + 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/libvirt-gconfig/libvirt-gconfig-clock.c b/libvirt-gconfig/libvirt-gconfig-clock.c index dc7932d..3deb725 100644 --- a/libvirt-gconfig/libvirt-gconfig-clock.c +++ b/libvirt-gconfig/libvirt-gconfig-clock.c @@ -27,6 +27,7 @@ #include #include "libvirt-gconfig/libvirt-gconfig.h" +#include "libvirt-gconfig/libvirt-gconfig-helpers-private.h" extern gboolean debugFlag; @@ -84,20 +85,16 @@ GVirConfigClock *gvir_config_clock_new_from_xml(const gchar *xml, void gvir_config_clock_set_offset(GVirConfigClock *klock, GVirConfigClockOffset offset) { -GEnumClass *enum_class; -GEnumValue *enum_value; xmlNodePtr node; +const char *offset_str; node = gvir_config_object_get_xml_node(GVIR_CONFIG_OBJECT(klock)); if (node == NULL) return; -enum_class = g_type_class_ref(GVIR_TYPE_CONFIG_CLOCK_OFFSET); -enum_value = g_enum_get_value(enum_class, offset); -if (enum_value != NULL) -xmlNewProp(node, (xmlChar*)"offset", (xmlChar*)enum_value->value_nick); - -g_type_class_unref(enum_class); - +offset_str = gvir_config_genum_get_nick(GVIR_TYPE_CONFIG_CLOCK_OFFSET, + offset); +if (offset_str != NULL) +xmlNewProp(node, (xmlChar*)"offset", (xmlChar*)offset_str); } void gvir_config_clock_set_timezone(GVirConfigClock *klock, 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..d069714 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; + +return NULL; +} -- 1.7.7 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-glib 05/37] 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. --- libvirt-gconfig/libvirt-gconfig-domain.c |8 libvirt-gconfig/libvirt-gconfig-domain.h |2 ++ libvirt-gconfig/libvirt-gconfig.sym |1 + 3 files changed, 11 insertions(+), 0 deletions(-) diff --git a/libvirt-gconfig/libvirt-gconfig-domain.c b/libvirt-gconfig/libvirt-gconfig-domain.c index f80720a..de60054 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain.c +++ b/libvirt-gconfig/libvirt-gconfig-domain.c @@ -237,3 +237,11 @@ 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; + +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 19e926c..30cabf5 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 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-glib 09/37] Add gobject boilerplate for GVirConfigOs
--- libvirt-gconfig/Makefile.am |2 + libvirt-gconfig/libvirt-gconfig-os.c | 80 ++ libvirt-gconfig/libvirt-gconfig-os.h | 67 libvirt-gconfig/libvirt-gconfig.h|3 +- libvirt-gconfig/libvirt-gconfig.sym |4 ++ 5 files changed, 155 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 a0dec08..384d7a3 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..b47e859 --- /dev/null +++ b/libvirt-gconfig/libvirt-gconfig-os.c @@ -0,0 +1,80 @@ +/* + * 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 + */ + +#include + +#include + +#include + +#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, Boston, MA 02111-1307 USA + * + * Author
[libvirt] [libvirt-glib 07/37] Implement gvir_config_clock_set_offset
--- libvirt-gconfig/libvirt-gconfig-clock.c | 19 +++ libvirt-gconfig/libvirt-gconfig-clock.h |8 libvirt-gconfig/libvirt-gconfig.sym |2 ++ 3 files changed, 29 insertions(+), 0 deletions(-) diff --git a/libvirt-gconfig/libvirt-gconfig-clock.c b/libvirt-gconfig/libvirt-gconfig-clock.c index 120d3a6..dc7932d 100644 --- a/libvirt-gconfig/libvirt-gconfig-clock.c +++ b/libvirt-gconfig/libvirt-gconfig-clock.c @@ -81,6 +81,25 @@ 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) +{ +GEnumClass *enum_class; +GEnumValue *enum_value; +xmlNodePtr node; + +node = gvir_config_object_get_xml_node(GVIR_CONFIG_OBJECT(klock)); +if (node == NULL) +return; +enum_class = g_type_class_ref(GVIR_TYPE_CONFIG_CLOCK_OFFSET); +enum_value = g_enum_get_value(enum_class, offset); +if (enum_value != NULL) +xmlNewProp(node, (xmlChar*)"offset", (xmlChar*)enum_value->value_nick); + +g_type_class_unref(enum_class); + +} + 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 30cabf5..f6f1256 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 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-glib 27/37] Add to creation test
--- libvirt-gconfig/tests/test-domain-create.c | 13 - 1 files changed, 12 insertions(+), 1 deletions(-) diff --git a/libvirt-gconfig/tests/test-domain-create.c b/libvirt-gconfig/tests/test-domain-create.c index db22eb5..3f3f973 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,17 @@ int main(void) gvir_config_device_disk_set_target_dev(disk, "hda"); devices = g_list_append(devices, disk); + +/* network interface node */ +GVirConfigInterface *interface; + + +interface = gvir_config_interface_new(); +gvir_config_interface_set_network_type(interface, + GVIR_CONFIG_INTERFACE_TYPE_NETWORK); +gvir_config_interface_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 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-glib 17/37] Add gobject boilerplate for GVirConfigDevice
This is an abstract type which will be used as a base class for all objects stored in the section of a domain. --- libvirt-gconfig/Makefile.am |2 + libvirt-gconfig/libvirt-gconfig-device.c | 62 + libvirt-gconfig/libvirt-gconfig-device.h | 64 ++ libvirt-gconfig/libvirt-gconfig.h|1 + libvirt-gconfig/libvirt-gconfig.sym |2 + 5 files changed, 131 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 384d7a3..86a7065 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 \ @@ -30,6 +31,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..6250e6d --- /dev/null +++ b/libvirt-gconfig/libvirt-gconfig-device.c @@ -0,0 +1,62 @@ +/* + * 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 + */ + +#include + +#include + +#include + +#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 + */ + +#if !defined(__LIBVIRT_GCONFIG_H__) && !defined(LIBVIRT_GCONFIG_BUILD) +#error "Only can be included directly." +#endif + +#ifndef __LIBVIRT_GCONFIG_DEVICE_H__ +#define __LIBVIRT_GCONFIG_DEVICE_H__ +
[libvirt] [libvirt-glib 04/37] Add some GVirConfigClock setters
--- libvirt-gconfig/libvirt-gconfig-clock.c | 32 ++ libvirt-gconfig/libvirt-gconfig-clock.h |5 libvirt-gconfig/libvirt-gconfig-domain.c |1 + libvirt-gconfig/libvirt-gconfig-domain.h |1 - libvirt-gconfig/libvirt-gconfig.sym |2 + 5 files changed, 40 insertions(+), 1 deletions(-) diff --git a/libvirt-gconfig/libvirt-gconfig-clock.c b/libvirt-gconfig/libvirt-gconfig-clock.c index d2650ad..120d3a6 100644 --- a/libvirt-gconfig/libvirt-gconfig-clock.c +++ b/libvirt-gconfig/libvirt-gconfig-clock.c @@ -80,3 +80,35 @@ 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; + +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; + +node = gvir_config_object_new_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-domain.c b/libvirt-gconfig/libvirt-gconfig-domain.c index c847c14..f80720a 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain.c +++ b/libvirt-gconfig/libvirt-gconfig-domain.c @@ -236,3 +236,4 @@ void gvir_config_domain_set_features(GVirConfigDomain *domain, } 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__ */ diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym index c76faab..19e926c 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 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-glib 16/37] 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 f88ae69..41390bd 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain.c +++ b/libvirt-gconfig/libvirt-gconfig-domain.c @@ -46,6 +46,7 @@ enum { PROP_0, PROP_NAME, PROP_MEMORY, +PROP_VCPU, PROP_FEATURES }; @@ -63,6 +64,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; @@ -86,6 +90,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; @@ -122,6 +129,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", @@ -192,6 +208,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 486b509..7660070 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 m
[libvirt] [libvirt-glib 11/37] Implement gvir_config_os_set_os_type
--- libvirt-gconfig/libvirt-gconfig-os.c | 14 ++ libvirt-gconfig/libvirt-gconfig-os.h |6 ++ libvirt-gconfig/libvirt-gconfig.sym |1 + 3 files changed, 21 insertions(+), 0 deletions(-) diff --git a/libvirt-gconfig/libvirt-gconfig-os.c b/libvirt-gconfig/libvirt-gconfig-os.c index b47e859..d4a04ae 100644 --- a/libvirt-gconfig/libvirt-gconfig-os.c +++ b/libvirt-gconfig/libvirt-gconfig-os.c @@ -27,6 +27,7 @@ #include #include "libvirt-gconfig/libvirt-gconfig.h" +#include "libvirt-gconfig/libvirt-gconfig-helpers-private.h" extern gboolean debugFlag; @@ -78,3 +79,16 @@ 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; + +node = gvir_config_object_new_child(GVIR_CONFIG_OBJECT(os), "type"); +if (node == NULL) +return; +type_str = gvir_config_genum_get_nick(GVIR_TYPE_CONFIG_OS_TYPE, type); +if (type_str != NULL) +xmlNodeSetContent(node, (xmlChar*)type_str); +} diff --git a/libvirt-gconfig/libvirt-gconfig-os.h b/libvirt-gconfig/libvirt-gconfig-os.h index 716f588..c6498ad 100644 --- a/libvirt-gconfig/libvirt-gconfig-os.h +++ b/libvirt-gconfig/libvirt-gconfig-os.h @@ -56,12 +56,18 @@ struct _GVirConfigOsClass gpointer padding[20]; }; +typedef enum { +GVIR_CONFIG_OS_TYPE_HVM, +GVIR_CONFIG_OS_TYPE_LINUX +} GVirConfigOsType; GType gvir_config_os_get_type(void); GVirConfigOs *gvir_config_os_new(void); GVirConfigOs *gvir_config_os_new_from_xml(const gchar *xml, GError **error); +void gvir_config_os_set_os_type(GVirConfigOs *os, GVirConfigOsType type); + G_END_DECLS #endif /* __LIBVIRT_GCONFIG_OS_H__ */ diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym index b1dcb81..176a2e2 100644 --- a/libvirt-gconfig/libvirt-gconfig.sym +++ b/libvirt-gconfig/libvirt-gconfig.sym @@ -52,6 +52,7 @@ LIBVIRT_GOBJECT_0.0.1 { gvir_config_object_validate; gvir_config_os_get_type; + gvir_config_os_type_get_type; gvir_config_os_new; gvir_config_os_new_from_xml; -- 1.7.7 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-glib 25/37] Add gvir_config_interface_set_network_type
--- libvirt-gconfig/libvirt-gconfig-interface.c | 15 +++ libvirt-gconfig/libvirt-gconfig-interface.h | 11 +++ libvirt-gconfig/libvirt-gconfig.sym |2 ++ 3 files changed, 28 insertions(+), 0 deletions(-) diff --git a/libvirt-gconfig/libvirt-gconfig-interface.c b/libvirt-gconfig/libvirt-gconfig-interface.c index 5eece82..d112123 100644 --- a/libvirt-gconfig/libvirt-gconfig-interface.c +++ b/libvirt-gconfig/libvirt-gconfig-interface.c @@ -83,3 +83,18 @@ GVirConfigInterface *gvir_config_interface_new_from_xml(const gchar *xml, return GVIR_CONFIG_INTERFACE(object); } +void gvir_config_interface_set_network_type(GVirConfigInterface *interface, +GVirConfigInterfaceNetworkType type) +{ +xmlNodePtr node; +const char *type_str; + +node = gvir_config_object_get_xml_node(GVIR_CONFIG_OBJECT(interface)); +if (node == NULL) +return; +type_str = gvir_config_genum_get_nick(GVIR_TYPE_CONFIG_INTERFACE_NETWORK_TYPE, + type); +if (type_str != NULL) { +xmlNewProp(node, (xmlChar*)"type", (xmlChar*)type_str); +} +} diff --git a/libvirt-gconfig/libvirt-gconfig-interface.h b/libvirt-gconfig/libvirt-gconfig-interface.h index 0728c29..9618611 100644 --- a/libvirt-gconfig/libvirt-gconfig-interface.h +++ b/libvirt-gconfig/libvirt-gconfig-interface.h @@ -56,12 +56,23 @@ struct _GVirConfigInterfaceClass gpointer padding[20]; }; +typedef enum { +GVIR_CONFIG_INTERFACE_TYPE_NETWORK, +GVIR_CONFIG_INTERFACE_TYPE_BRIDGE, +GVIR_CONFIG_INTERFACE_TYPE_USER, +GVIR_CONFIG_INTERFACE_TYPE_ETHERNET, +GVIR_CONFIG_INTERFACE_TYPE_DIRECT, +GVIR_CONFIG_INTERFACE_TYPE_MCAST, +GVIR_CONFIG_INTERFACE_TYPE_SERVER +} GVirConfigInterfaceNetworkType; GType gvir_config_interface_get_type(void); GVirConfigInterface *gvir_config_interface_new(void); GVirConfigInterface *gvir_config_interface_new_from_xml(const gchar *xml, GError **error); +void gvir_config_interface_set_network_type(GVirConfigInterface *interface, +GVirConfigInterfaceNetworkType type); G_END_DECLS diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym index cb0d035..e9f1513 100644 --- a/libvirt-gconfig/libvirt-gconfig.sym +++ b/libvirt-gconfig/libvirt-gconfig.sym @@ -49,8 +49,10 @@ LIBVIRT_GOBJECT_0.0.1 { gvir_config_domain_snapshot_new_from_xml; gvir_config_interface_get_type; + gvir_config_interface_network_type_get_type; gvir_config_interface_new; gvir_config_interface_new_from_xml; + gvir_config_interface_set_network_type; gvir_config_network_get_type; gvir_config_network_new; -- 1.7.7 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-glib 31/37] Add GVirConfigDeviceVideo
--- 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 e14d90a..71fe027 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-input.h \ + libvirt-gconfig-device-video.h \ libvirt-gconfig-domain.h \ libvirt-gconfig-domain-snapshot.h \ libvirt-gconfig-graphics-spice.h \ @@ -38,6 +39,7 @@ GCONFIG_SOURCE_FILES = \ libvirt-gconfig-device.c \ libvirt-gconfig-device-disk.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..23736db --- /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 + */ + +#include + +#include + +#include + +#include "libvirt-gconfig/libvirt-gconfig.h" +#include "libvirt-gconfig/libvirt-gconfig-helpers-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; + +node = gvir_config_object_new_child(GVIR_CONFIG_OBJECT(video), +"model", TRUE); +if (node == NULL) +return; +model_str = gvir_config_genum_get_nick(GVIR_TYPE_CONFIG_DEVICE_VIDEO_MODEL, +
[libvirt] [libvirt-glib 19/37] Add various GVirConfigDeviceDisk setters
--- libvirt-gconfig/libvirt-gconfig-device-disk.c | 46 + libvirt-gconfig/libvirt-gconfig-device-disk.h | 25 + libvirt-gconfig/libvirt-gconfig.sym |6 +++ 3 files changed, 77 insertions(+), 0 deletions(-) diff --git a/libvirt-gconfig/libvirt-gconfig-device-disk.c b/libvirt-gconfig/libvirt-gconfig-device-disk.c index ba2ef47..9981ae8 100644 --- a/libvirt-gconfig/libvirt-gconfig-device-disk.c +++ b/libvirt-gconfig/libvirt-gconfig-device-disk.c @@ -27,6 +27,7 @@ #include #include "libvirt-gconfig/libvirt-gconfig.h" +#include "libvirt-gconfig/libvirt-gconfig-helpers-private.h" extern gboolean debugFlag; @@ -80,3 +81,48 @@ 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; + +node = gvir_config_object_get_xml_node(GVIR_CONFIG_OBJECT(disk)); +if (node == NULL) +return; +type_str = gvir_config_genum_get_nick(GVIR_TYPE_CONFIG_DEVICE_DISK_TYPE, + type); +if (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; + +node = gvir_config_object_get_xml_node(GVIR_CONFIG_OBJECT(disk)); +if (node == NULL) +return; +type_str = gvir_config_genum_get_nick(GVIR_TYPE_CONFIG_DEVICE_DISK_GUEST_DEVICE_TYPE, + type); +if (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; + +node = gvir_config_object_get_xml_node(GVIR_CONFIG_OBJECT(disk)); +if (node == NULL) +return; +type_str = gvir_config_genum_get_nick(GVIR_TYPE_CONFIG_DEVICE_DISK_SNAPSHOT_TYPE, + type); +if (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 4e9d622..2850672 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 b19e1c1..76ffc4c 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; + gvir_config_device_disk_guest_device_type_get_type; + gvir_config_device_disk_snapshot_type_get_type; + gvir_config_device_disk_type_get_type; gvir_config_device_disk_new; gvir_config_device_disk_new_from_xml; + gvir_config_device_disk_set_snapshot_type; + gvir_config_device_disk_set_guest_device_type; + gvir_
[libvirt] [libvirt-glib 30/37] Add basic GVirConfigGraphicsSpice
Only the (non-TLS) port can be set on it --- libvirt-gconfig/Makefile.am |2 + libvirt-gconfig/libvirt-gconfig-graphics-spice.c | 98 ++ libvirt-gconfig/libvirt-gconfig-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, 182 insertions(+), 0 deletions(-) create mode 100644 libvirt-gconfig/libvirt-gconfig-graphics-spice.c create mode 100644 libvirt-gconfig/libvirt-gconfig-graphics-spice.h diff --git a/libvirt-gconfig/Makefile.am b/libvirt-gconfig/Makefile.am index dcb5caa..e14d90a 100644 --- a/libvirt-gconfig/Makefile.am +++ b/libvirt-gconfig/Makefile.am @@ -17,6 +17,7 @@ GCONFIG_HEADER_FILES = \ libvirt-gconfig-device-input.h \ libvirt-gconfig-domain.h \ libvirt-gconfig-domain-snapshot.h \ + libvirt-gconfig-graphics-spice.h \ libvirt-gconfig-helpers.h \ libvirt-gconfig-interface.h \ libvirt-gconfig-interface-network.h \ @@ -41,6 +42,7 @@ GCONFIG_SOURCE_FILES = \ libvirt-gconfig-domain-snapshot.c \ libvirt-gconfig-enum-types.c \ libvirt-gconfig-enum-types.h \ + libvirt-gconfig-graphics-spice.c \ libvirt-gconfig-helpers.c \ libvirt-gconfig-interface.c \ libvirt-gconfig-interface-network.c \ diff --git a/libvirt-gconfig/libvirt-gconfig-graphics-spice.c b/libvirt-gconfig/libvirt-gconfig-graphics-spice.c new file mode 100644 index 000..acb2304 --- /dev/null +++ b/libvirt-gconfig/libvirt-gconfig-graphics-spice.c @@ -0,0 +1,98 @@ +/* + * libvirt-gobject-config-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 + */ + +#include + +#include + +#include + +#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_GRAPHICS_SPICE_GET_PRIVATE(obj) \ +(G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_TYPE_CONFIG_GRAPHICS_SPICE, GVirConfigGraphicsSpicePrivate)) + +struct _GVirConfigGraphicsSpicePrivate +{ +gboolean unused; +}; + +G_DEFINE_TYPE(GVirConfigGraphicsSpice, gvir_config_graphics_spice, GVIR_TYPE_CONFIG_DEVICE); + + +static void gvir_config_graphics_spice_class_init(GVirConfigGraphicsSpiceClass *klass) +{ + +g_type_class_add_private(klass, sizeof(GVirConfigGraphicsSpicePrivate)); +} + + +static void gvir_config_graphics_spice_init(GVirConfigGraphicsSpice *graphics_spice) +{ +GVirConfigGraphicsSpicePrivate *priv; + +DEBUG("Init GVirConfigGraphicsSpice=%p", graphics_spice); + +priv = graphics_spice->priv = GVIR_CONFIG_GRAPHICS_SPICE_GET_PRIVATE(graphics_spice); + +memset(priv, 0, sizeof(*priv)); +} + + +GVirConfigGraphicsSpice *gvir_config_graphics_spice_new(void) +{ +GVirConfigObject *object; + +object = gvir_config_object_new(GVIR_TYPE_CONFIG_GRAPHICS_SPICE, +"graphics", NULL); +//xmlNewProp(doc->children, (xmlChar*)"type", (xmlChar*)"spice"); +return GVIR_CONFIG_GRAPHICS_SPICE(object); +} + +GVirConfigGraphicsSpice *gvir_config_graphics_spice_new_from_xml(const gchar *xml, + GError **error) +{ +GVirConfigObject *object; + +object = gvir_config_object_new_from_xml(GVIR_TYPE_CONFIG_GRAPHICS_SPICE, + "graphics", NULL, xml, error); +//xmlNewProp(doc->children, (xmlChar*)"type", (xmlChar*)"spice"); +return GVIR_CONFIG_GRAPHICS_SPICE(object); +} + +void gvir_config_graphics_spice_set_port(GVirConfigGraphicsSpice *graphics, + unsigned int port) +{ +xmlNodePtr node; +char *port_str; + +node = gvir_config_object_get_xml_node(GVIR_CONFIG_OBJE
[libvirt] [libvirt-glib 14/37] Implement gvir_config_domain_set_os
--- libvirt-gconfig/libvirt-gconfig-domain.c |9 + libvirt-gconfig/libvirt-gconfig-domain.h |2 ++ libvirt-gconfig/libvirt-gconfig.h|4 +++- libvirt-gconfig/libvirt-gconfig.sym |1 + 4 files changed, 15 insertions(+), 1 deletions(-) diff --git a/libvirt-gconfig/libvirt-gconfig-domain.c b/libvirt-gconfig/libvirt-gconfig-domain.c index de60054..f88ae69 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain.c +++ b/libvirt-gconfig/libvirt-gconfig-domain.c @@ -245,3 +245,12 @@ 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; + +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 #include #include -#include #include #include #include @@ -43,4 +42,7 @@ #include #include +/* Must come last since it uses types defined in the other headers */ +#include + #endif /* __LIBVIRT_GCONFIG_H__ */ diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym index 20b0150..486b509 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 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-glib 20/37] Improve gvir_config_object_new_child
Add an "overwrite" boolean argument to indicate what to do when the child we are about to create already exists. --- libvirt-gconfig/libvirt-gconfig-clock.c |3 +- libvirt-gconfig/libvirt-gconfig-domain.c |2 +- libvirt-gconfig/libvirt-gconfig-object.c | 39 +++-- libvirt-gconfig/libvirt-gconfig-object.h |3 +- libvirt-gconfig/libvirt-gconfig-os.c | 11 +--- 5 files changed, 43 insertions(+), 15 deletions(-) diff --git a/libvirt-gconfig/libvirt-gconfig-clock.c b/libvirt-gconfig/libvirt-gconfig-clock.c index 3deb725..7cf35bb 100644 --- a/libvirt-gconfig/libvirt-gconfig-clock.c +++ b/libvirt-gconfig/libvirt-gconfig-clock.c @@ -119,7 +119,8 @@ void gvir_config_clock_set_variable_offset(GVirConfigClock *klock, xmlNodePtr node; char *offset_str; -node = gvir_config_object_new_child(GVIR_CONFIG_OBJECT(klock), "clock"); +node = gvir_config_object_new_child(GVIR_CONFIG_OBJECT(klock), +"clock", TRUE); if (node == NULL) return; diff --git a/libvirt-gconfig/libvirt-gconfig-domain.c b/libvirt-gconfig/libvirt-gconfig-domain.c index 41390bd..88b46fb 100644 --- a/libvirt-gconfig/libvirt-gconfig-domain.c +++ b/libvirt-gconfig/libvirt-gconfig-domain.c @@ -256,7 +256,7 @@ void gvir_config_domain_set_features(GVirConfigDomain *domain, GStrv it; features_node = gvir_config_object_new_child(GVIR_CONFIG_OBJECT(domain), - "features"); + "features", TRUE); for (it = features; *it != NULL; it++) { xmlNodePtr node; diff --git a/libvirt-gconfig/libvirt-gconfig-object.c b/libvirt-gconfig/libvirt-gconfig-object.c index 598ac0c..fd7d2d8 100644 --- a/libvirt-gconfig/libvirt-gconfig-object.c +++ b/libvirt-gconfig/libvirt-gconfig-object.c @@ -294,34 +294,57 @@ char *gvir_config_object_get_node_content(GVirConfigObject *object, return gvir_config_xml_get_child_element_content_glib(node, node_name); } -void -gvir_config_object_set_child(GVirConfigObject *object, xmlNodePtr child) +static xmlNodePtr +gvir_config_object_set_child_internal(GVirConfigObject *object, + xmlNodePtr child, + gboolean overwrite) { xmlNodePtr parent_node; xmlNodePtr old_node; parent_node = gvir_config_object_get_xml_node(GVIR_CONFIG_OBJECT(object)); -g_return_if_fail (parent_node != NULL); +g_return_val_if_fail (parent_node != NULL, 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, child); -xmlFreeNode(old_node); +if (overwrite) { +old_node = xmlReplaceNode(old_node, child); +xmlFreeNode(old_node); +} else { +return old_node; +} } else { xmlAddChild(parent_node, child); } + +return NULL; +} + +void +gvir_config_object_set_child(GVirConfigObject *object, xmlNodePtr child) +{ +gvir_config_object_set_child_internal(object, child, TRUE); } xmlNodePtr -gvir_config_object_new_child(GVirConfigObject *object, const char *child_name) +gvir_config_object_new_child(GVirConfigObject *object, + const char *child_name, + gboolean overwrite) { xmlNodePtr new_node; +xmlNodePtr old_node; new_node = xmlNewDocNode(NULL, NULL, (xmlChar *)child_name, NULL); -gvir_config_object_set_child(object, new_node); +old_node = gvir_config_object_set_child_internal(object, new_node, + overwrite); +if ((old_node != NULL) && !overwrite) { +xmlFreeNode(new_node); +return old_node; +} + return new_node; } @@ -332,7 +355,7 @@ void gvir_config_object_set_node_content(GVirConfigObject *object, xmlNodePtr node; xmlChar *encoded_data; -node = gvir_config_object_new_child(object, node_name); +node = gvir_config_object_new_child(object, node_name, TRUE); g_return_if_fail(node != NULL); encoded_data = xmlEncodeEntitiesReentrant(node->doc, (xmlChar *)value); diff --git a/libvirt-gconfig/libvirt-gconfig-object.h b/libvirt-gconfig/libvirt-gconfig-object.h index 8e67b92..096cefb 100644 --- a/libvirt-gconfig/libvirt-gconfig-object.h +++ b/libvirt-gconfig/libvirt-gconfig-object.h @@ -79,7 +79,8 @@ char *gvir_config_object_get_node_content(GVirConfigObject *object, guint64 gvir_config_object_get_node_content_uint64(GVirConfigObject *object, const char *node_name); xmlNodePtr gvir_config_object_new_child(GVirConfigObject *object, -c
[libvirt] [libvirt-glib 18/37] Add gobject boilerplate for GVirConfigDeviceDisk
--- libvirt-gconfig/Makefile.am |2 + libvirt-gconfig/libvirt-gconfig-device-disk.c | 82 + libvirt-gconfig/libvirt-gconfig-device-disk.h | 68 libvirt-gconfig/libvirt-gconfig.h |1 + libvirt-gconfig/libvirt-gconfig.sym |4 + 5 files changed, 157 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 86a7065..82063df 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 \ @@ -32,6 +33,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..ba2ef47 --- /dev/null +++ b/libvirt-gconfig/libvirt-gconfig-device-disk.c @@ -0,0 +1,82 @@ +/* + * 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 + */ + +#include + +#include + +#include + +#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..4e9d622 --- /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 distributed in the hope that it will be usefu
[libvirt] [libvirt-glib 28/37] 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. --- libvirt-gconfig/Makefile.am|2 + .../libvirt-gconfig-interface-network.c| 106 .../libvirt-gconfig-interface-network.h| 70 + libvirt-gconfig/libvirt-gconfig-interface.c| 71 +- libvirt-gconfig/libvirt-gconfig-interface.h| 18 libvirt-gconfig/libvirt-gconfig.h |1 + libvirt-gconfig/libvirt-gconfig.sym| 10 +- libvirt-gconfig/tests/test-domain-create.c |9 +- 8 files changed, 189 insertions(+), 98 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 82063df..c74d123 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.h \ 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..304712d --- /dev/null +++ b/libvirt-gconfig/libvirt-gconfig-interface-network.c @@ -0,0 +1,106 @@ +/* + * 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 + * Author: Christophe Fergeau + */ + +#include + +#include + +#include "libvirt-gconfig/libvirt-gconfig.h" +#include "libvirt-gconfig/libvirt-gconfig-helpers-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, + "schema", DATADIR "/libvirt/schemas/interface.rng", +
[libvirt] [libvirt-glib 22/37] More GVirConfigDeviceDisk setters
--- libvirt-gconfig/libvirt-gconfig-device-disk.c | 88 - libvirt-gconfig/libvirt-gconfig-device-disk.h | 10 +++ libvirt-gconfig/libvirt-gconfig.sym |7 ++- 3 files changed, 102 insertions(+), 3 deletions(-) diff --git a/libvirt-gconfig/libvirt-gconfig-device-disk.c b/libvirt-gconfig/libvirt-gconfig-device-disk.c index 9981ae8..29de68b 100644 --- a/libvirt-gconfig/libvirt-gconfig-device-disk.c +++ b/libvirt-gconfig/libvirt-gconfig-device-disk.c @@ -38,7 +38,7 @@ extern gboolean debugFlag; struct _GVirConfigDeviceDiskPrivate { -gboolean unused; +GVirConfigDeviceDiskType type; }; G_DEFINE_TYPE(GVirConfigDeviceDisk, gvir_config_device_disk, GVIR_TYPE_CONFIG_DEVICE); @@ -93,8 +93,10 @@ void gvir_config_device_disk_set_type(GVirConfigDeviceDisk *disk, return; type_str = gvir_config_genum_get_nick(GVIR_TYPE_CONFIG_DEVICE_DISK_TYPE, type); -if (type_str != NULL) +if (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, @@ -126,3 +128,85 @@ void gvir_config_device_disk_set_snapshot_type(GVirConfigDeviceDisk *disk, if (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; + +if (disk->priv->type == GVIR_CONFIG_DEVICE_DISK_DIR) { +/* I don't know what attribute name to use for 'dir' */ +g_warning("set_source not implemented for 'dir' disk nodes"); +return; +} + +source_node = gvir_config_object_new_child(GVIR_CONFIG_OBJECT(disk), + "source", TRUE); +if (source_node == NULL) +return; + +switch (disk->priv->type) { +case GVIR_CONFIG_DEVICE_DISK_FILE: +attribute_name = "file"; +break; +case GVIR_CONFIG_DEVICE_DISK_BLOCK: +attribute_name = "block"; +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; + +node = gvir_config_object_new_child(GVIR_CONFIG_OBJECT(disk), +"driver", FALSE); +if (node == NULL) +return; +xmlNewProp(node, (xmlChar*)"name", (xmlChar*)driver_name); + +} + +void gvir_config_device_disk_set_driver_type(GVirConfigDeviceDisk *disk, + const char *driver_type) +{ +xmlNodePtr node; + +node = gvir_config_object_new_child(GVIR_CONFIG_OBJECT(disk), +"driver", FALSE); +if (node == NULL) +return; +xmlNewProp(node, (xmlChar*)"type", (xmlChar*)driver_type); +} + +void gvir_config_device_disk_set_target_bus(GVirConfigDeviceDisk *disk, +const char *bus) +{ +xmlNodePtr node; + +node = gvir_config_object_new_child(GVIR_CONFIG_OBJECT(disk), +"target", FALSE); +if (node == NULL) +return; +xmlNewProp(node, (xmlChar*)"bus", (xmlChar*)bus); +} + +void gvir_config_device_disk_set_target_dev(GVirConfigDeviceDisk *disk, +const char *dev) +{ +xmlNodePtr node; + +node = gvir_config_object_new_child(GVIR_CONFIG_OBJECT(disk), +"target", FALSE); +if (node == NULL) +return; +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 2850672..3e25e9f 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
[libvirt] [libvirt-glib 26/37] Add gvir_config_interface_set_source
The way it's done is just a band-aid though. The need for this 'type' member in GVirConfigInterface and GVirConfigDeviceDisk is a clear indication that they should be separate class. --- libvirt-gconfig/libvirt-gconfig-interface.c | 30 ++- libvirt-gconfig/libvirt-gconfig-interface.h |2 + libvirt-gconfig/libvirt-gconfig.sym |1 + 3 files changed, 32 insertions(+), 1 deletions(-) diff --git a/libvirt-gconfig/libvirt-gconfig-interface.c b/libvirt-gconfig/libvirt-gconfig-interface.c index d112123..0993ab9 100644 --- a/libvirt-gconfig/libvirt-gconfig-interface.c +++ b/libvirt-gconfig/libvirt-gconfig-interface.c @@ -36,7 +36,7 @@ extern gboolean debugFlag; struct _GVirConfigInterfacePrivate { -gboolean unused; +GVirConfigInterfaceNetworkType type; }; G_DEFINE_TYPE(GVirConfigInterface, gvir_config_interface, GVIR_TYPE_CONFIG_DEVICE); @@ -96,5 +96,33 @@ void gvir_config_interface_set_network_type(GVirConfigInterface *interface, type); if (type_str != NULL) { xmlNewProp(node, (xmlChar*)"type", (xmlChar*)type_str); +interface->priv->type = type; } } + +void gvir_config_interface_set_source(GVirConfigInterface *interface, + const char *source) +{ +xmlNodePtr source_node; +const char *attribute_name; + +if (interface->priv->type != GVIR_CONFIG_INTERFACE_TYPE_NETWORK) { +/* I don't know what attribute name to use for 'dir' */ +g_warning("set_source not implemented for non-'network' interface nodes"); +return; +} + +source_node = gvir_config_object_new_child(GVIR_CONFIG_OBJECT(interface), + "source", TRUE); +if (source_node == NULL) +return; + +switch (interface->priv->type) { +case GVIR_CONFIG_INTERFACE_TYPE_NETWORK: +attribute_name = "network"; +break; +default: +g_return_if_reached(); +} +xmlNewProp(source_node, (xmlChar*)attribute_name, (xmlChar*)source); +} diff --git a/libvirt-gconfig/libvirt-gconfig-interface.h b/libvirt-gconfig/libvirt-gconfig-interface.h index 9618611..8de3334 100644 --- a/libvirt-gconfig/libvirt-gconfig-interface.h +++ b/libvirt-gconfig/libvirt-gconfig-interface.h @@ -74,6 +74,8 @@ GVirConfigInterface *gvir_config_interface_new_from_xml(const gchar *xml, void gvir_config_interface_set_network_type(GVirConfigInterface *interface, GVirConfigInterfaceNetworkType type); +void gvir_config_interface_set_source(GVirConfigInterface *interface, + const char *source); G_END_DECLS #endif /* __LIBVIRT_GCONFIG_INTERFACE_H__ */ diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym index e9f1513..886690e 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_new; gvir_config_interface_new_from_xml; gvir_config_interface_set_network_type; + gvir_config_interface_set_source; gvir_config_network_get_type; gvir_config_network_new; -- 1.7.7 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-glib 12/37] Add more GVirConfigOs setters
--- libvirt-gconfig/libvirt-gconfig-os.c | 85 ++ libvirt-gconfig/libvirt-gconfig-os.h | 19 libvirt-gconfig/libvirt-gconfig.sym |8 +++ 3 files changed, 112 insertions(+), 0 deletions(-) diff --git a/libvirt-gconfig/libvirt-gconfig-os.c b/libvirt-gconfig/libvirt-gconfig-os.c index d4a04ae..cfe827e 100644 --- a/libvirt-gconfig/libvirt-gconfig-os.c +++ b/libvirt-gconfig/libvirt-gconfig-os.c @@ -92,3 +92,88 @@ void gvir_config_os_set_os_type(GVirConfigOs *os, GVirConfigOsType type) if (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; + +node = gvir_config_object_new_child(GVIR_CONFIG_OBJECT(os), "bootmenu"); +if (node == NULL) +return; +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; + +node = gvir_config_object_new_child(GVIR_CONFIG_OBJECT(os), "bios"); +if (node == NULL) +return; +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; + +node = gvir_config_object_new_child(GVIR_CONFIG_OBJECT(os), "smbios"); +if (node == NULL) +return; +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; + +os_node = gvir_config_object_get_xml_node(GVIR_CONFIG_OBJECT(os)); +if (os_node == NULL) +return; + +node = os_node->children; +while (node != NULL) { +xmlNodePtr next_node; +next_node = node->next; +if (strcmp("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)); +if (dev != NULL) { +node = xmlNewDocNode(NULL, NULL, (xmlChar*)"boot", NULL); +xmlNewProp(node, (xmlChar*)"dev", (xmlChar*)dev); +xmlAddChild(os_node, node); +} +} +} diff --git a/libvirt-gconfig/libvirt-gconfig-os.h b/libvirt-gconfig/libvirt-gconfig-os.h index c6498ad..87027da 100644 --- a/libvirt-gconfig/libvirt-gconfig-os.h +++ b/libvirt-gconfig/libvirt-gconfig-os.h @@ -61,12 +61,31 @@ typedef enum { GVIR_CONFIG_OS_TYPE_LINUX } GVirConfigOsType; +typedef enum { +GVIR_CONFIG_OS_SMBIOS_MODE_EMULATE, +GVIR_CONFIG_OS_SMBIOS_MODE_HOST, +GVIR_CONFIG_OS_SMBIOS_MODE_SYSINFO +} GVirConfigOsSmBiosMode; + +typedef enum { +GVIR_CONFIG_OS_BOOT_DEVICE_FD, +GVIR_CONFIG_OS_BOOT_DEVICE_HD, +GVIR_CONFIG_OS_BOOT_DEVICE_CDROM, +GVIR_CONFIG_OS_BOOT_DEVICE_NETWORK +} GVirConfigOsBootDevice; + GType gvir_config_os_get_type(void); GVirConfigOs *gvir_config_os_new(void); GVirConfigOs *gvir_config_os_new_from_xml(const gchar *xml, GError **error); void gvir_config_os_set_os_type(GVirConfigOs *os, GVirConfigOsType type); +void gvir_config_os_set_boot_devices(GVirConfigOs *os, GList *boot_devices); +void gvir_config_os_set_loader(GVirConfigOs *os, const char * loader); +void gvir_config_os_set_smbios_mode(GVirConfigOs *os, +GVirConfigOsSmBiosMode mode); +void gvir_config_os_enable_boot_menu(GVirConfigOs *os, gboolean enable); +void gvir_config_os_bios_enable_serial(GVirConfigOs *os, gboolean enable); G_END_DECLS diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym index 176a2e2..3466129 100644 --- a/libvirt-gconfig/libvirt-gconfig.sym +++ b/libvirt-gconfig/libvirt-gconfig.sym @@ -52,9 +52,17 @@ LIBVIRT_GOBJECT_0.0.1 { gvir_config_object_validate; gvir_config_os_get_type; + gvir_config_os_boot_device_get_type; + gvir_config_os_sm_bios_mode_get_type; gvir_config_os_type_get_typ
[libvirt] [libvirt-glib 32/37] Add gobject boilerplate for chardev handling
--- libvirt-gconfig/Makefile.am |6 ++ libvirt-gconfig/libvirt-gconfig-chardev-source.c | 62 libvirt-gconfig/libvirt-gconfig-chardev-source.h | 64 + libvirt-gconfig/libvirt-gconfig-chardev-target.c | 62 libvirt-gconfig/libvirt-gconfig-chardev-target.h | 64 + libvirt-gconfig/libvirt-gconfig-device-chardev.c | 82 ++ libvirt-gconfig/libvirt-gconfig-device-chardev.h | 71 +++ libvirt-gconfig/libvirt-gconfig.h|3 + libvirt-gconfig/libvirt-gconfig.sym | 10 +++ 9 files changed, 424 insertions(+), 0 deletions(-) create mode 100644 libvirt-gconfig/libvirt-gconfig-chardev-source.c create mode 100644 libvirt-gconfig/libvirt-gconfig-chardev-source.h create mode 100644 libvirt-gconfig/libvirt-gconfig-chardev-target.c create mode 100644 libvirt-gconfig/libvirt-gconfig-chardev-target.h create mode 100644 libvirt-gconfig/libvirt-gconfig-device-chardev.c create mode 100644 libvirt-gconfig/libvirt-gconfig-device-chardev.h diff --git a/libvirt-gconfig/Makefile.am b/libvirt-gconfig/Makefile.am index 71fe027..3144955 100644 --- a/libvirt-gconfig/Makefile.am +++ b/libvirt-gconfig/Makefile.am @@ -11,8 +11,11 @@ GCONFIG_HEADER_FILES = \ libvirt-gconfig.h \ libvirt-gconfig-object.h \ libvirt-gconfig-capabilities.h \ + libvirt-gconfig-chardev-source.h \ + libvirt-gconfig-chardev-target.h \ libvirt-gconfig-clock.h \ libvirt-gconfig-device.h \ + libvirt-gconfig-device-chardev.h \ libvirt-gconfig-device-disk.h \ libvirt-gconfig-device-input.h \ libvirt-gconfig-device-video.h \ @@ -35,8 +38,11 @@ noinst_HEADERS = \ GCONFIG_SOURCE_FILES = \ libvirt-gconfig-object.c \ libvirt-gconfig-capabilities.c \ + libvirt-gconfig-chardev-source.c \ + libvirt-gconfig-chardev-target.c \ libvirt-gconfig-clock.c \ libvirt-gconfig-device.c \ + libvirt-gconfig-device-chardev.c \ libvirt-gconfig-device-disk.c \ libvirt-gconfig-device-input.c \ libvirt-gconfig-device-video.c \ diff --git a/libvirt-gconfig/libvirt-gconfig-chardev-source.c b/libvirt-gconfig/libvirt-gconfig-chardev-source.c new file mode 100644 index 000..82eff4f --- /dev/null +++ b/libvirt-gconfig/libvirt-gconfig-chardev-source.c @@ -0,0 +1,62 @@ +/* + * libvirt-gobject-config-chardev-source.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 + */ + +#include + +#include + +#include + +#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_CHARDEV_SOURCE_GET_PRIVATE(obj) \ +(G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_TYPE_CONFIG_CHARDEV_SOURCE, GVirConfigChardevSourcePrivate)) + +struct _GVirConfigChardevSourcePrivate +{ +gboolean unused; +}; + +G_DEFINE_ABSTRACT_TYPE(GVirConfigChardevSource, gvir_config_chardev_source, GVIR_TYPE_CONFIG_OBJECT); + + +static void gvir_config_chardev_source_class_init(GVirConfigChardevSourceClass *klass) +{ + +g_type_class_add_private(klass, sizeof(GVirConfigChardevSourcePrivate)); +} + + +static void gvir_config_chardev_source_init(GVirConfigChardevSource *chardev_source) +{ +GVirConfigChardevSourcePrivate *priv; + +DEBUG("Init GVirConfigChardevSource=%p", chardev_source); + +priv = chardev_source->priv = GVIR_CONFIG_CHARDEV_SOURCE_GET_PRIVATE(chardev_source); + +memset(priv, 0, sizeof(*priv)); +} diff --git a/libvirt-gconfig/libvirt-gconfig-chardev-source.h b/libvirt-gconfig/libvirt-gconfig-chardev-source.h new file mode 100644 index 000..5a4c8fe --- /dev/null +++ b/libvirt-gconfig/libvirt-gconfi
[libvirt] [libvirt-glib 36/37] Add GVirConfigChardevTargetConsole
--- libvirt-gconfig/Makefile.am|2 + .../libvirt-gconfig-chardev-target-console.c | 83 .../libvirt-gconfig-chardev-target-console.h | 68 libvirt-gconfig/libvirt-gconfig.h |1 + libvirt-gconfig/libvirt-gconfig.sym|4 + 5 files changed, 158 insertions(+), 0 deletions(-) create mode 100644 libvirt-gconfig/libvirt-gconfig-chardev-target-console.c create mode 100644 libvirt-gconfig/libvirt-gconfig-chardev-target-console.h diff --git a/libvirt-gconfig/Makefile.am b/libvirt-gconfig/Makefile.am index 8df46f5..12e78fb 100644 --- a/libvirt-gconfig/Makefile.am +++ b/libvirt-gconfig/Makefile.am @@ -14,6 +14,7 @@ GCONFIG_HEADER_FILES = \ libvirt-gconfig-chardev-source.h \ libvirt-gconfig-chardev-source-pty.h \ libvirt-gconfig-chardev-target.h \ + libvirt-gconfig-chardev-target-console.h \ libvirt-gconfig-clock.h \ libvirt-gconfig-device.h \ libvirt-gconfig-device-chardev.h \ @@ -42,6 +43,7 @@ GCONFIG_SOURCE_FILES = \ libvirt-gconfig-chardev-source.c \ libvirt-gconfig-chardev-source-pty.c \ libvirt-gconfig-chardev-target.c \ + libvirt-gconfig-chardev-target-console.c \ libvirt-gconfig-clock.c \ libvirt-gconfig-device.c \ libvirt-gconfig-device-chardev.c \ diff --git a/libvirt-gconfig/libvirt-gconfig-chardev-target-console.c b/libvirt-gconfig/libvirt-gconfig-chardev-target-console.c new file mode 100644 index 000..6e9a555 --- /dev/null +++ b/libvirt-gconfig/libvirt-gconfig-chardev-target-console.c @@ -0,0 +1,83 @@ +/* + * libvirt-gobject-config-chardev-target-console.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 + */ + +#include + +#include + +#include + +#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_CHARDEV_TARGET_CONSOLE_GET_PRIVATE(obj) \ +(G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_TYPE_CONFIG_CHARDEV_TARGET_CONSOLE, GVirConfigChardevTargetConsolePrivate)) + +struct _GVirConfigChardevTargetConsolePrivate +{ +gboolean unused; +}; + +G_DEFINE_TYPE(GVirConfigChardevTargetConsole, gvir_config_chardev_target_console, GVIR_TYPE_CONFIG_CHARDEV_TARGET); + + +static void gvir_config_chardev_target_console_class_init(GVirConfigChardevTargetConsoleClass *klass) +{ +g_type_class_add_private(klass, sizeof(GVirConfigChardevTargetConsolePrivate)); + gvir_config_chardev_target_class_set_nick(GVIR_TYPE_CONFIG_CHARDEV_TARGET_CONSOLE, + "console"); +} + + +static void gvir_config_chardev_target_console_init(GVirConfigChardevTargetConsole *chardev_target_console) +{ +GVirConfigChardevTargetConsolePrivate *priv; + +DEBUG("Init GVirConfigChardevTargetConsole=%p", chardev_target_console); + +priv = chardev_target_console->priv = GVIR_CONFIG_CHARDEV_TARGET_CONSOLE_GET_PRIVATE(chardev_target_console); + +memset(priv, 0, sizeof(*priv)); +} + + +GVirConfigChardevTargetConsole *gvir_config_chardev_target_console_new(void) +{ +GVirConfigObject *object; + +object = gvir_config_object_new(GVIR_TYPE_CONFIG_CHARDEV_TARGET_CONSOLE, +"target", NULL); +return GVIR_CONFIG_CHARDEV_TARGET_CONSOLE(object); +} + +GVirConfigChardevTargetConsole *gvir_config_chardev_target_console_new_from_xml(gchar *xml, + GError **error) +{ +GVirConfigObject *object; + +object = gvir_config_object_new_from_xml(GVIR_TYPE_CONFIG_CHARDEV_TARGET_CONSOLE, + "target", NULL, xml, error); +return GVIR_CONFIG_CHARDEV_TARGET_CONSOLE(object); +} diff --git a/libvirt-gconfig/libvirt-gconfig-cha
[libvirt] [libvirt-glib 33/37] Implement gvir_config_device_chardev_set_source
--- libvirt-gconfig/libvirt-gconfig-chardev-source.c | 44 +- libvirt-gconfig/libvirt-gconfig-chardev-source.h |2 + libvirt-gconfig/libvirt-gconfig-device-chardev.c | 18 + libvirt-gconfig/libvirt-gconfig.sym |2 + 4 files changed, 64 insertions(+), 2 deletions(-) diff --git a/libvirt-gconfig/libvirt-gconfig-chardev-source.c b/libvirt-gconfig/libvirt-gconfig-chardev-source.c index 82eff4f..cc11423 100644 --- a/libvirt-gconfig/libvirt-gconfig-chardev-source.c +++ b/libvirt-gconfig/libvirt-gconfig-chardev-source.c @@ -40,12 +40,20 @@ struct _GVirConfigChardevSourcePrivate gboolean unused; }; -G_DEFINE_ABSTRACT_TYPE(GVirConfigChardevSource, gvir_config_chardev_source, GVIR_TYPE_CONFIG_OBJECT); +struct _GVirConfigChardevSourceClassPrivate +{ +char *nick; +}; +typedef struct _GVirConfigChardevSourceClassPrivate GVirConfigChardevSourceClassPrivate; +#define GVIR_CONFIG_CHARDEV_SOURCE_CLASS_GET_PRIVATE(klass) \ +(G_TYPE_CLASS_GET_PRIVATE((klass), GVIR_TYPE_CONFIG_CHARDEV_SOURCE, GVirConfigChardevSourceClassPrivate)) + +G_DEFINE_ABSTRACT_TYPE_WITH_CODE(GVirConfigChardevSource, gvir_config_chardev_source, GVIR_TYPE_CONFIG_OBJECT, + g_type_add_class_private(g_define_type_id, sizeof(GVirConfigChardevSourceClassPrivate))); static void gvir_config_chardev_source_class_init(GVirConfigChardevSourceClass *klass) { - g_type_class_add_private(klass, sizeof(GVirConfigChardevSourcePrivate)); } @@ -60,3 +68,35 @@ static void gvir_config_chardev_source_init(GVirConfigChardevSource *chardev_sou memset(priv, 0, sizeof(*priv)); } + +const char *gvir_config_chardev_source_class_get_nick(GType type) +{ +GVirConfigChardevSourceClass *klass; +GVirConfigChardevSourceClassPrivate *priv; + +klass = g_type_class_peek(type); +if (klass == NULL) +return NULL; + +priv = GVIR_CONFIG_CHARDEV_SOURCE_CLASS_GET_PRIVATE(klass); +if (priv == NULL) +return NULL; +return priv->nick; +} + +void gvir_config_chardev_source_class_set_nick(GType type, const char *nick) +{ +GVirConfigChardevSourceClass *klass; +GVirConfigChardevSourceClassPrivate *priv; + +klass = g_type_class_ref(type); +if (klass == NULL) +return; + +priv = GVIR_CONFIG_CHARDEV_SOURCE_CLASS_GET_PRIVATE(klass); +if (priv == NULL) +return; +g_free(priv->nick); +priv->nick = g_strdup(nick); +g_type_class_unref(klass); +} diff --git a/libvirt-gconfig/libvirt-gconfig-chardev-source.h b/libvirt-gconfig/libvirt-gconfig-chardev-source.h index 5a4c8fe..e306eb2 100644 --- a/libvirt-gconfig/libvirt-gconfig-chardev-source.h +++ b/libvirt-gconfig/libvirt-gconfig-chardev-source.h @@ -58,6 +58,8 @@ struct _GVirConfigChardevSourceClass GType gvir_config_chardev_source_get_type(void); +const char *gvir_config_chardev_source_class_get_nick(GType type); +void gvir_config_chardev_source_class_set_nick(GType type, const char *nick); G_END_DECLS diff --git a/libvirt-gconfig/libvirt-gconfig-device-chardev.c b/libvirt-gconfig/libvirt-gconfig-device-chardev.c index d4ec23f..10f3d57 100644 --- a/libvirt-gconfig/libvirt-gconfig-device-chardev.c +++ b/libvirt-gconfig/libvirt-gconfig-device-chardev.c @@ -80,3 +80,21 @@ GVirConfigDeviceChardev *gvir_config_device_chardev_new_from_xml(const gchar *xm "", NULL, xml, error); return GVIR_CONFIG_DEVICE_CHARDEV(object); } + +void gvir_config_device_chardev_set_source(GVirConfigDeviceChardev *chardev, + GVirConfigChardevSource *source) +{ +xmlNodePtr node; +xmlNodePtr source_node; +const char *source_type; + +node = gvir_config_object_get_xml_node(GVIR_CONFIG_OBJECT(chardev)); +source_node = gvir_config_object_get_xml_node(GVIR_CONFIG_OBJECT(source)); +if ((node == NULL) || (source_node == NULL)) +return; +source_type = gvir_config_chardev_source_class_get_nick(G_OBJECT_TYPE(source)); +g_return_if_fail(source_type != NULL); +xmlNewProp(node, (xmlChar*)"type", (xmlChar*)source_type); + +gvir_config_object_set_child(GVIR_CONFIG_OBJECT(chardev), source_node); +} diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym index fe4376b..df08b59 100644 --- a/libvirt-gconfig/libvirt-gconfig.sym +++ b/libvirt-gconfig/libvirt-gconfig.sym @@ -5,6 +5,8 @@ LIBVIRT_GOBJECT_0.0.1 { gvir_config_capabilities_new_from_xml; gvir_config_chardev_source_get_type; + gvir_config_chardev_source_class_get_nick; + gvir_config_chardev_source_class_set_nick; gvir_config_chardev_target_get_type; -- 1.7.7 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 5/8] Enable the blkdeviotune command in virsh
OK. On Thu, Nov 10, 2011 at 04:32:55AM +0800, Lei HH Li wrote: > Support virsh command blkdeviotune. Can set or query a block disk > I/O throttle setting. > > Signed-off-by: Zhi Yong Wu > Signed-off-by: Lei Li > --- > tools/virsh.c | 146 > +++ > tools/virsh.pod | 23 + > 2 files changed, 169 insertions(+), 0 deletions(-) > > diff --git a/tools/virsh.c b/tools/virsh.c > index 83dc3c7..df2b399 100644 > --- a/tools/virsh.c > +++ b/tools/virsh.c > @@ -6023,6 +6023,151 @@ cmdBlockJob(vshControl *ctl, const vshCmd *cmd) > return true; > } > > +/* > + * "blkdeviotune" command > + */ > +static const vshCmdInfo info_blkdeviotune[] = { > +{"help", N_("Set or query a block disk I/O throttle setting.")}, > +{"desc", N_("Set or query a block disk I/O throttle setting.\n" \ > +"To query the block disk I/O throttle setting use the > following" \ > +" command: \n\n" \ > +"virsh # blkdeviotune ")}, > +{NULL, NULL} > +}; > + > +static const vshCmdOptDef opts_blkdeviotune[] = { > +{"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")}, > +{"device", VSH_OT_DATA, VSH_OFLAG_REQ, N_("block device")}, > +{"total_bytes_sec", VSH_OT_INT, VSH_OFLAG_NONE, N_("total throughput > limit in bytes per second/s")}, > +{"read_bytes_sec", VSH_OT_INT, VSH_OFLAG_NONE, N_("read throughput limit > in bytes per second/s")}, > +{"write_bytes_sec", VSH_OT_INT, VSH_OFLAG_NONE, N_("write throughput > limit in bytes per second/s")}, > +{"total_iops_sec", VSH_OT_INT, VSH_OFLAG_NONE, N_("total I/O operations > limit per second/s")}, > +{"read_iops_sec", VSH_OT_INT, VSH_OFLAG_NONE, N_("read I/O operations > limit per second/s")}, > +{"write_iops_sec", VSH_OT_INT, VSH_OFLAG_NONE, N_("write I/O operations > limit per second/s")}, > +{"config", VSH_OT_BOOL, 0, N_("affect next boot")}, > +{"live", VSH_OT_BOOL, 0, N_("affect running domain")}, > +{"current", VSH_OT_BOOL, 0, N_("affect current domain")}, > +{NULL, 0, 0, NULL} > +}; > + > +static bool > +cmdBlkdeviotune(vshControl *ctl, const vshCmd *cmd) > +{ > +virDomainPtr dom = NULL; > +const char *name, *disk; > +virDomainBlockIoTuneInfo info; > +virDomainBlockIoTuneInfo reply; > +unsigned int flags = 0; > +int ret = -1; > +int rv = 0; > +int set = 0; > +int current = vshCommandOptBool(cmd, "current"); > +int config = vshCommandOptBool(cmd, "config"); > +int live = vshCommandOptBool(cmd, "live"); > + > +if (current) { > +if (live || config) { > +vshError(ctl, "%s", _("--current must be specified > exclusively")); > +return false; > +} > +flags = VIR_DOMAIN_AFFECT_CURRENT; > +} else { > +if (config) > +flags |= VIR_DOMAIN_AFFECT_CONFIG; > +if (live) > +flags |= VIR_DOMAIN_AFFECT_LIVE; > +} > + > +memset(&info, 0, sizeof(info)); > + > +if (!vshConnectionUsability(ctl, ctl->conn)) > +goto out; > + > +if (!(dom = vshCommandOptDomain(ctl, cmd, &name))) > +goto out; > + > +if (vshCommandOptString(cmd, "device", &disk) < 0) > +goto out; > + > +if ((rv = vshCommandOptULongLong(cmd, "total_bytes_sec", > &info.total_bytes_sec)) < 0) { > +vshError(ctl, "%s", > + _("Unable to parse integer parameter")); > +goto out; > +} else if (rv > 0) { > +set++; > +} > + > +if ((rv = vshCommandOptULongLong(cmd, "read_bytes_sec", > &info.read_bytes_sec)) < 0) { > +vshError(ctl, "%s", > + _("Unable to parse integer parameter")); > +goto out; > +} else if (rv > 0) { > +set++; > +} > + > +if ((rv = vshCommandOptULongLong(cmd, "write_bytes_sec", > &info.write_bytes_sec)) < 0) { > +vshError(ctl, "%s", > + _("Unable to parse integer parameter")); > +goto out; > +} else if (rv > 0) { > +set++; > +} > + > +if ((rv = vshCommandOptULongLong(cmd, "total_iops_sec", > &info.total_iops_sec)) < 0) { > +vshError(ctl, "%s", > + _("Unable to parse integer parameter")); > +goto out; > +} else if (rv > 0) { > +set++; > +} > + > +if ((rv = vshCommandOptULongLong(cmd, "read_iops_sec", > &info.read_iops_sec)) < 0) { > +vshError(ctl, "%s", > + _("Unable to parse integer parameter")); > +goto out; > +} else if (rv > 0) { > +set++; > +} > + > +if ((rv = vshCommandOptULongLong(cmd, "write_iops_sec", > &info.write_iops_sec)) < 0) { > +vshError(ctl, "%s", > + _("Unable to parse integer parameter")); > +goto out; > +} else if (rv > 0) { > +set++; > +} > + > +if (!set) { > + > +ret = virDomainGetBlockIoTune(dom, disk, &reply, flags); > + >
[libvirt] [libvirt-glib 34/37] Implement gvir_config_device_chardev_set_target
--- libvirt-gconfig/libvirt-gconfig-chardev-target.c | 42 +- libvirt-gconfig/libvirt-gconfig-chardev-target.h |2 + libvirt-gconfig/libvirt-gconfig-device-chardev.c | 18 + libvirt-gconfig/libvirt-gconfig.sym |2 + 4 files changed, 63 insertions(+), 1 deletions(-) diff --git a/libvirt-gconfig/libvirt-gconfig-chardev-target.c b/libvirt-gconfig/libvirt-gconfig-chardev-target.c index a9e5a20..64430ea 100644 --- a/libvirt-gconfig/libvirt-gconfig-chardev-target.c +++ b/libvirt-gconfig/libvirt-gconfig-chardev-target.c @@ -40,8 +40,16 @@ struct _GVirConfigChardevTargetPrivate gboolean unused; }; -G_DEFINE_ABSTRACT_TYPE(GVirConfigChardevTarget, gvir_config_chardev_target, GVIR_TYPE_CONFIG_OBJECT); +struct _GVirConfigChardevTargetClassPrivate +{ +char *nick; +}; +typedef struct _GVirConfigChardevTargetClassPrivate GVirConfigChardevTargetClassPrivate; +#define GVIR_CONFIG_CHARDEV_TARGET_CLASS_GET_PRIVATE(klass) \ +(G_TYPE_CLASS_GET_PRIVATE((klass), GVIR_TYPE_CONFIG_CHARDEV_TARGET, GVirConfigChardevTargetClassPrivate)) +G_DEFINE_ABSTRACT_TYPE_WITH_CODE(GVirConfigChardevTarget, gvir_config_chardev_target, GVIR_TYPE_CONFIG_OBJECT, + g_type_add_class_private(g_define_type_id, sizeof(GVirConfigChardevTargetClassPrivate))); static void gvir_config_chardev_target_class_init(GVirConfigChardevTargetClass *klass) { @@ -60,3 +68,35 @@ static void gvir_config_chardev_target_init(GVirConfigChardevTarget *chardev_tar memset(priv, 0, sizeof(*priv)); } + +const char *gvir_config_chardev_target_class_get_nick(GType type) +{ +GVirConfigChardevTargetClass *klass; +GVirConfigChardevTargetClassPrivate *priv; + +klass = g_type_class_peek(type); +if (klass == NULL) +return NULL; + +priv = GVIR_CONFIG_CHARDEV_TARGET_CLASS_GET_PRIVATE(klass); +if (priv == NULL) +return NULL; +return priv->nick; +} + +void gvir_config_chardev_target_class_set_nick(GType type, const char *nick) +{ +GVirConfigChardevTargetClass *klass; +GVirConfigChardevTargetClassPrivate *priv; + +klass = g_type_class_ref(type); +if (klass == NULL) +return; + +priv = GVIR_CONFIG_CHARDEV_TARGET_CLASS_GET_PRIVATE(klass); +if (priv == NULL) +return; +g_free(priv->nick); +priv->nick = g_strdup(nick); +g_type_class_unref(klass); +} diff --git a/libvirt-gconfig/libvirt-gconfig-chardev-target.h b/libvirt-gconfig/libvirt-gconfig-chardev-target.h index 41fd875..53a10a1 100644 --- a/libvirt-gconfig/libvirt-gconfig-chardev-target.h +++ b/libvirt-gconfig/libvirt-gconfig-chardev-target.h @@ -58,6 +58,8 @@ struct _GVirConfigChardevTargetClass GType gvir_config_chardev_target_get_type(void); +const char *gvir_config_chardev_target_class_get_nick(GType type); +void gvir_config_chardev_target_class_set_nick(GType type, const char *nick); G_END_DECLS diff --git a/libvirt-gconfig/libvirt-gconfig-device-chardev.c b/libvirt-gconfig/libvirt-gconfig-device-chardev.c index 10f3d57..62859fe 100644 --- a/libvirt-gconfig/libvirt-gconfig-device-chardev.c +++ b/libvirt-gconfig/libvirt-gconfig-device-chardev.c @@ -98,3 +98,21 @@ void gvir_config_device_chardev_set_source(GVirConfigDeviceChardev *chardev, gvir_config_object_set_child(GVIR_CONFIG_OBJECT(chardev), source_node); } + +void gvir_config_device_chardev_set_target(GVirConfigDeviceChardev *chardev, + GVirConfigChardevTarget *target) +{ +xmlNodePtr node; +xmlNodePtr target_node; +const char *target_type; + +node = gvir_config_object_get_xml_node(GVIR_CONFIG_OBJECT(chardev)); +target_node = gvir_config_object_get_xml_node(GVIR_CONFIG_OBJECT(target)); +if ((node == NULL) || (target_node == NULL)) +return; +target_type = gvir_config_chardev_target_class_get_nick(G_OBJECT_TYPE(target)); +g_return_if_fail(target_type != NULL); +xmlNodeSetName(node, (xmlChar*)target_type); + +gvir_config_object_set_child(GVIR_CONFIG_OBJECT(chardev), target_node); +} diff --git a/libvirt-gconfig/libvirt-gconfig.sym b/libvirt-gconfig/libvirt-gconfig.sym index df08b59..0889a53 100644 --- a/libvirt-gconfig/libvirt-gconfig.sym +++ b/libvirt-gconfig/libvirt-gconfig.sym @@ -9,6 +9,8 @@ LIBVIRT_GOBJECT_0.0.1 { gvir_config_chardev_source_class_set_nick; gvir_config_chardev_target_get_type; + gvir_config_chardev_target_class_get_nick; + gvir_config_chardev_target_class_set_nick; gvir_config_clock_get_type; gvir_config_clock_offset_get_type; -- 1.7.7 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [libvirt-glib 37/37] Add test for "console" node creation
--- libvirt-gconfig/tests/test-domain-create.c | 17 + 1 files changed, 17 insertions(+), 0 deletions(-) diff --git a/libvirt-gconfig/tests/test-domain-create.c b/libvirt-gconfig/tests/test-domain-create.c index ba08a9f..cca3316 100644 --- a/libvirt-gconfig/tests/test-domain-create.c +++ b/libvirt-gconfig/tests/test-domain-create.c @@ -127,13 +127,30 @@ int main(void) GVIR_CONFIG_DEVICE_VIDEO_MODEL_QXL); devices = g_list_append(devices, GVIR_CONFIG_DEVICE(video)); +/* console node */ +GVirConfigDeviceChardev *chardev; +GVirConfigChardevTargetConsole *console; +GVirConfigChardevSourcePty *pty; +chardev = gvir_config_device_chardev_new(); +pty = gvir_config_chardev_source_pty_new(); +gvir_config_device_chardev_set_source(chardev, + GVIR_CONFIG_CHARDEV_SOURCE(pty)); + +console = gvir_config_chardev_target_console_new(); +gvir_config_device_chardev_set_target(chardev, + GVIR_CONFIG_CHARDEV_TARGET(console)); +devices = g_list_append(devices, GVIR_CONFIG_DEVICE(chardev)); + + +/* attach devices to domain */ 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 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] Wiki spam!
On Thu, Nov 10, 2011 at 03:27:10PM -0500, Cole Robinson wrote: > On 11/10/2011 03:10 PM, Daniel P. Berrange wrote: > > On Thu, Nov 10, 2011 at 02:50:30PM -0500, Cole Robinson wrote: > >> The wiki's been spammed, see November 9 for example: > >> > >> http://wiki.libvirt.org/page/Special:Recentchanges > >> > >> virt-manager.org had a similar problem. Any one know any good proactive > >> ways to prevent this? > > > > I have enabled a captcha for all account creation pages, and for any > > edit which inserts a URL. > > > > I will also be enabling mandatory email address confirmation for all > > accounts. > > > > Hmm, I thought et.redhat.com couldn't send email? Do those changes > affect virt-manager.org as well? It can't send email at the moment, but that is getting fixed. Once fixed, I'll turn on the email confirmation for all wikis. 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] [libvirt-glib 35/37] Add GVirConfigChardevSourcePty
--- libvirt-gconfig/Makefile.am|2 + .../libvirt-gconfig-chardev-source-pty.c | 82 .../libvirt-gconfig-chardev-source-pty.h | 68 libvirt-gconfig/libvirt-gconfig.h |1 + libvirt-gconfig/libvirt-gconfig.sym|4 + 5 files changed, 157 insertions(+), 0 deletions(-) create mode 100644 libvirt-gconfig/libvirt-gconfig-chardev-source-pty.c create mode 100644 libvirt-gconfig/libvirt-gconfig-chardev-source-pty.h diff --git a/libvirt-gconfig/Makefile.am b/libvirt-gconfig/Makefile.am index 3144955..8df46f5 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-chardev-source.h \ + libvirt-gconfig-chardev-source-pty.h \ libvirt-gconfig-chardev-target.h \ libvirt-gconfig-clock.h \ libvirt-gconfig-device.h \ @@ -39,6 +40,7 @@ GCONFIG_SOURCE_FILES = \ libvirt-gconfig-object.c \ libvirt-gconfig-capabilities.c \ libvirt-gconfig-chardev-source.c \ + libvirt-gconfig-chardev-source-pty.c \ libvirt-gconfig-chardev-target.c \ libvirt-gconfig-clock.c \ libvirt-gconfig-device.c \ diff --git a/libvirt-gconfig/libvirt-gconfig-chardev-source-pty.c b/libvirt-gconfig/libvirt-gconfig-chardev-source-pty.c new file mode 100644 index 000..f0a2c8d --- /dev/null +++ b/libvirt-gconfig/libvirt-gconfig-chardev-source-pty.c @@ -0,0 +1,82 @@ +/* + * libvirt-gobject-config-chardev-source-pty.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 + */ + +#include + +#include + +#include + +#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_CHARDEV_SOURCE_PTY_GET_PRIVATE(obj) \ +(G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_TYPE_CONFIG_CHARDEV_SOURCE_PTY, GVirConfigChardevSourcePtyPrivate)) + +struct _GVirConfigChardevSourcePtyPrivate +{ +gboolean unused; +}; + +G_DEFINE_TYPE(GVirConfigChardevSourcePty, gvir_config_chardev_source_pty, GVIR_TYPE_CONFIG_CHARDEV_SOURCE); + + +static void gvir_config_chardev_source_pty_class_init(GVirConfigChardevSourcePtyClass *klass) +{ +g_type_class_add_private(klass, sizeof(GVirConfigChardevSourcePtyPrivate)); + gvir_config_chardev_source_class_set_nick(GVIR_TYPE_CONFIG_CHARDEV_SOURCE_PTY, "pty"); +} + + +static void gvir_config_chardev_source_pty_init(GVirConfigChardevSourcePty *pty) +{ +GVirConfigChardevSourcePtyPrivate *priv; + +DEBUG("Init GVirConfigChardevSourcePty=%p", pty); + +priv = pty->priv = GVIR_CONFIG_CHARDEV_SOURCE_PTY_GET_PRIVATE(pty); + +memset(priv, 0, sizeof(*priv)); +} + + +GVirConfigChardevSourcePty *gvir_config_chardev_source_pty_new(void) +{ +GVirConfigObject *object; + +object = gvir_config_object_new(GVIR_TYPE_CONFIG_CHARDEV_SOURCE_PTY, +"source", NULL); +return GVIR_CONFIG_CHARDEV_SOURCE_PTY(object); +} + +GVirConfigChardevSourcePty *gvir_config_chardev_source_pty_new_from_xml(const gchar *xml, +GError **error) +{ +GVirConfigObject *object; + +object = gvir_config_object_new_from_xml(GVIR_TYPE_CONFIG_CHARDEV_SOURCE_PTY, + "source", NULL, xml, error); +return GVIR_CONFIG_CHARDEV_SOURCE_PTY(object); +} diff --git a/libvirt-gconfig/libvirt-gconfig-chardev-source-pty.h b/libvirt-gconfig/libvirt-gconfig-chardev-source-pty.h new file mode 100644 index 000..39b40bc --- /dev/null +++ b/libvirt-gconfig/libvirt-gconfig-chardev-source-pty.h @@ -0,0 +1,68 @@ +/* + * libvirt-gobject-chardev-source-pty.c: libvirt gobject integration +
Re: [libvirt] [PATCH 7/8] Support virDomain{Set, Get}BlockIoThrottle in the python API
Looks good. On Thu, Nov 10, 2011 at 04:32:57AM +0800, Lei HH Li wrote: > Python support for both set and get block I/O throttle. > > Signed-off-by: Zhi Yong Wu > Signed-off-by: Lei Li > --- > python/generator.py |2 + > python/libvirt-override-api.xml | 16 +++ > python/libvirt-override.c | 85 > +++ > 3 files changed, 103 insertions(+), 0 deletions(-) > > diff --git a/python/generator.py b/python/generator.py > index 71afdb7..88c52b9 100755 > --- a/python/generator.py > +++ b/python/generator.py > @@ -414,6 +414,8 @@ skip_impl = ( > 'virDomainGetBlockJobInfo', > 'virDomainMigrateGetMaxSpeed', > 'virDomainBlockStatsFlags', > +'virDomainSetBlockIoTune', > +'virDomainGetBlockIoTune', > ) > > qemu_skip_impl = ( > diff --git a/python/libvirt-override-api.xml b/python/libvirt-override-api.xml > index ef02f34..e8d9138 100644 > --- a/python/libvirt-override-api.xml > +++ b/python/libvirt-override-api.xml > @@ -375,5 +375,21 @@ > > > > + > + Change the I/O throttle for a block device > + > + > + > + > + > + > + > + Get the I/O throttle a block device > + > + > + > + > + > + > > > diff --git a/python/libvirt-override.c b/python/libvirt-override.c > index 1759bae..d4b023a 100644 > --- a/python/libvirt-override.c > +++ b/python/libvirt-override.c > @@ -3195,6 +3195,89 @@ LIBVIRT_END_ALLOW_THREADS; > return ret; > } > > +static PyObject * > +libvirt_virDomainSetBlockIoTune(PyObject *self ATTRIBUTE_UNUSED, > +PyObject *args) > +{ > +virDomainPtr domain; > +PyObject *pyobj_domain, *pyinfo; > +const char *disk; > +unsigned int flags; > +virDomainBlockIoTuneInfo info; > +int c_ret; > +PyObject *ret; > + > +if (!PyArg_ParseTuple(args, (char *)"Ozi:virDomainSetBlockIoTune", > + &pyobj_domain, &disk, &pyinfo, &flags)) > +return(NULL); > +domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain); > + > +info.total_bytes_sec = (unsigned long > long)PyLong_AsLongLong(PyDict_GetItem(pyinfo, > +libvirt_constcharPtrWrap("bps"))); > +info.read_bytes_sec = (unsigned long > long)PyLong_AsLongLong(PyDict_GetItem(pyinfo, > + libvirt_constcharPtrWrap("bps_rd"))); > +info.write_bytes_sec = (unsigned long > long)PyLong_AsLongLong(PyDict_GetItem(pyinfo, > +libvirt_constcharPtrWrap("bps_wr"))); > +info.total_iops_sec = (unsigned long > long)PyLong_AsLongLong(PyDict_GetItem(pyinfo, > + libvirt_constcharPtrWrap("iops"))); > +info.read_iops_sec = (unsigned long > long)PyLong_AsLongLong(PyDict_GetItem(pyinfo, > + libvirt_constcharPtrWrap("iops_rd"))); > +info.write_iops_sec = (unsigned long > long)PyLong_AsLongLong(PyDict_GetItem(pyinfo, > + libvirt_constcharPtrWrap("iops_wr"))); > + > +LIBVIRT_BEGIN_ALLOW_THREADS; > +c_ret = virDomainSetBlockIoTune(domain, disk, &info, flags); > +LIBVIRT_END_ALLOW_THREADS; > + > +if (c_ret < 0) { > +return VIR_PY_NONE; > +} > + > +return VIR_PY_INT_SUCCESS; > +} > + > +static PyObject * > +libvirt_virDomainGetBlockIoTune(PyObject *self ATTRIBUTE_UNUSED, > +PyObject *args) > +{ > +virDomainPtr domain; > +PyObject *pyobj_domain; > +const char *disk; > +unsigned int flags; > +virDomainBlockIoTuneInfo reply; > +int c_ret; > +PyObject *ret; > + > +if (!PyArg_ParseTuple(args, (char *)"Oi:virDomainGetBlockIoTune", > + &pyobj_domain, &disk, &flags)) > +return(NULL); > +domain = (virDomainPtr) PyvirDomain_Get(pyobj_domain); > + > +LIBVIRT_BEGIN_ALLOW_THREADS; > +c_ret = virDomainGetBlockIoTune(domain, disk, &reply, flags); > +LIBVIRT_END_ALLOW_THREADS; > + > +if (c_ret < 0) > +return VIR_PY_NONE; > + > +if ((ret = PyDict_New()) == NULL) > +return VIR_PY_NONE; > + > +PyDict_SetItem(ret, libvirt_constcharPtrWrap("total_bytes_sec"), > + libvirt_ulonglongWrap(reply.total_bytes_sec)); > +PyDict_SetItem(ret, libvirt_constcharPtrWrap("read_bytes_sec"), > + libvirt_ulonglongWrap(reply.read_bytes_sec)); > +PyDict_SetItem(ret, libvirt_constcharPtrWrap("write_bytes_sec"), > + libvirt_ulonglongWrap(reply.write_bytes_sec)); > +PyDict_SetItem(ret, libvirt_constcharPtrWrap("total_iops_sec"), > + libvirt_ulonglongWrap(reply.total_iops_sec)); > +PyDict_SetItem(ret, libvirt_constcharPtrWrap("read_iops_sec"), > + libvirt_ulonglongWrap(reply.read_iops_sec)); > +PyDict_SetItem(ret, libvirt_constcharPtrWrap("write_iops_sec"), > + libvirt_ulonglongWr
Re: [libvirt] [PATCH libvirt-glib 1/3] Add GVirDomainDevice abstract class
Hey, a few preliminary comments, On Thu, Nov 10, 2011 at 09:33:41PM +0100, Marc-André Lureau wrote: > + > +G_GNUC_INTERNAL > +virDomainPtr gvir_domain_device_get_domain_handle(GVirDomainDevice *self) G_GNUC_INTERNAL isn't needed here since it's the default setting for symbols not listed in the .sym file. Christophe pgpE8UFEHrT5W.pgp Description: PGP signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH libvirt-glib 2/3] Add GVirDomainInterface
A few preliminary remark below, they apply to the next patch as well. On Thu, Nov 10, 2011 at 09:33:42PM +0100, Marc-André Lureau wrote: > --- > libvirt-gobject/Makefile.am|2 + > libvirt-gobject/libvirt-gobject-domain-interface.c | 213 > > libvirt-gobject/libvirt-gobject-domain-interface.h | 81 > libvirt-gobject/libvirt-gobject.h |1 + > libvirt-gobject/libvirt-gobject.sym|4 + > 5 files changed, 301 insertions(+), 0 deletions(-) > create mode 100644 libvirt-gobject/libvirt-gobject-domain-interface.c > create mode 100644 libvirt-gobject/libvirt-gobject-domain-interface.h > > diff --git a/libvirt-gobject/Makefile.am b/libvirt-gobject/Makefile.am > index 56a047e..8b59109 100644 > --- a/libvirt-gobject/Makefile.am > +++ b/libvirt-gobject/Makefile.am > @@ -8,6 +8,7 @@ GOBJECT_HEADER_FILES = \ > libvirt-gobject-main.h \ > libvirt-gobject-domain-snapshot.h \ > libvirt-gobject-domain-device.h \ > + libvirt-gobject-domain-interface.h \ > libvirt-gobject-domain.h \ > libvirt-gobject-interface.h \ > libvirt-gobject-network.h \ > @@ -23,6 +24,7 @@ GOBJECT_SOURCE_FILES = \ > libvirt-gobject-main.c \ > libvirt-gobject-domain-snapshot.c \ > libvirt-gobject-domain-device.c \ > + libvirt-gobject-domain-interface.c \ > libvirt-gobject-domain.c \ > libvirt-gobject-interface.c \ > libvirt-gobject-network.c \ > diff --git a/libvirt-gobject/libvirt-gobject-domain-interface.c > b/libvirt-gobject/libvirt-gobject-domain-interface.c > new file mode 100644 > index 000..65a5467 > --- /dev/null > +++ b/libvirt-gobject/libvirt-gobject-domain-interface.c > @@ -0,0 +1,213 @@ > +/* > + * libvirt-gobject-domain-interface.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: Marc-André Lureau > + */ > + > +#include > + > +#include > +#include > + > +#include "libvirt-glib/libvirt-glib.h" > +#include "libvirt-gobject/libvirt-gobject.h" > + > +#include "libvirt-gobject/libvirt-gobject-domain-device-private.h" > + > +extern gboolean debugFlag; > + > +#define DEBUG(fmt, ...) do { if (G_UNLIKELY(debugFlag)) g_debug(fmt, ## > __VA_ARGS__); } while (0) > + > +#define GVIR_DOMAIN_INTERFACE_GET_PRIVATE(obj) \ > +(G_TYPE_INSTANCE_GET_PRIVATE((obj), GVIR_TYPE_DOMAIN_INTERFACE, > GVirDomainInterfacePrivate)) > + > +struct _GVirDomainInterfacePrivate > +{ > +gchar *path; > +}; > + > +G_DEFINE_TYPE(GVirDomainInterface, gvir_domain_interface, > GVIR_TYPE_DOMAIN_DEVICE); > + > +enum { > +PROP_0, > +PROP_PATH, > +}; > + > +#define GVIR_DOMAIN_INTERFACE_ERROR gvir_domain_interface_error_quark() > + > + > +static GQuark > +gvir_domain_interface_error_quark(void) > +{ > +return g_quark_from_static_string("gvir-domain-interface"); > +} > + > +static void gvir_domain_interface_get_property(GObject *object, > + guint prop_id, > + GValue *value, > + GParamSpec *pspec) > +{ > +GVirDomainInterface *self = GVIR_DOMAIN_INTERFACE(object); > +GVirDomainInterfacePrivate *priv = self->priv; > + > +switch (prop_id) { > +case PROP_PATH: > +g_value_set_string(value, priv->path); > +break; > + > +default: > +G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); > +} > +} > + > + > +static void gvir_domain_interface_set_property(GObject *object, > + guint prop_id, > + const GValue *value, > + GParamSpec *pspec) > +{ > +GVirDomainInterface *self = GVIR_DOMAIN_INTERFACE(object); > +GVirDomainInterfacePrivate *priv = self->priv; > + > +switch (prop_id) { > +case PROP_PATH: > +if (p
Re: [libvirt] [PATCH libvirt-glib 1/3] Add GVirDomainDevice abstract class
Hi - Mensaje original - > > +G_GNUC_INTERNAL > > +virDomainPtr gvir_domain_device_get_domain_handle(GVirDomainDevice > > *self) > > G_GNUC_INTERNAL isn't needed here since it's the default setting for > symbols not listed in the .sym file. > I think it's better to be explicit about it. It's a way to declare in the code that this function is private, without having to look into the sym file. I wish we could do the same for the rest of the prviate functions. regards -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH libvirt-glib 2/3] Add GVirDomainInterface
Hi > On Thu, Nov 10, 2011 at 09:33:42PM +0100, Marc-André Lureau wrote: > > +case PROP_PATH: > > +if (priv->path) > > +g_free(priv->path); > > You can safely call g_free on a NULL pointer, this makes the code a > bit > simpler, there are several occurrences of this in the 2 patches. Correct, I forgot. I will fix that. > > +static GVirDomainInterfaceStats * > > +gvir_domain_interface_stats_copy(GVirDomainInterfaceStats *stats) > > +{ > > +return g_slice_dup(GVirDomainInterfaceStats, stats); > > +} > > Do we really need to use GSlice here? I consider GSlice as something > to use > when you want to make many allocations of same-size objects, will we > allocate many of these stats objects? Yes, it's frequently allocated (1/second), and kept in memory too for history. > > +typedef struct _GVirDomainInterfaceStats GVirDomainInterfaceStats; > > +struct _GVirDomainInterfaceStats > > +{ > > +gint64 rx_bytes; > > +gint64 rx_packets; > > +gint64 rx_errs; > > +gint64 rx_drop; > > +gint64 tx_bytes; > > +gint64 tx_packets; > > +gint64 tx_errs; > > +gint64 tx_drop; > > +}; > > 2 questions about this: > * should we use more explicit names (which probably means longer > ones)? I don't mind. I just copy&pasted libvirt here, which I like because you can directly map it to libvirt struct. > * how do we handle ABI compatibility the day we need to add fields to > this > struct? It's only a returned structure, allocated by the lib, so I guess that's fine to append fields later, right? regards -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [Qemu-devel] qemu and qemu.git -> Migration + disk stress introduces qcow2 corruptions
On 11/10/2011 12:27 PM, Anthony Liguori wrote: On 11/10/2011 02:55 AM, Avi Kivity wrote: If we have to delay the release for a month to get it right, we should. Not that I think we have to. Adding libvirt to the discussion. What does libvirt actually do in the monitor prior to migration completing on the destination? The least invasive way of doing delayed open of block devices is probably to make -incoming create a monitor and run a main loop before the block devices (and full device model) is initialized. Since this isolates the changes strictly to migration, I'd feel okay doing this for 1.0 (although it might need to be in the stable branch). This won't work. libvirt needs things to be initialized. Plus, once loadvm gets to loading the device model, the device model (and BDSes) need to be fully initialized. I think I've convinced myself that without proper clustered shared storage, cache=none is a hard requirement. That goes for iSCSI and NFS. I don't see a way to do migration safely with NFS and there's no way to really solve the page cache problem with iSCSI. Even with the reopen, it's racing against the close on the source. If you look at Daniel's description of what libvirt is doing and then compare that to Juan's patches, there's a race condition regarding whether the source gets closed before the reopen happens. cache=none seems to be the only way to solve this. Live migration with qcow2 or any other image format is just not going to work right now even with proper clustered storage. I think doing a block level flush cache interface and letting block devices decide how to do it is the best approach. Regards, Anthony Liguori I know a monitor can run like this as I've done it before but some of the commands will not behave as expected so it's pretty important to be comfortable with what commands are actually being used in this mode. Regards, Anthony Liguori -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [RFC PATCH 0/8 v3] Summary on block IO throttle
Hi Lei, I've tested this and found that it works well except for one small thing. When the domain is running and I change one of the throttle settings using the --config option in virsh, the on-disk domain xml file is properly updated, but the command 'virsh dumpxml' returns the old version. Is this how it is supposed to work? Otherwise, it seems to work as advertised (based on my sniff testing). Tested-by: Adam Litke On Thu, Nov 10, 2011 at 04:32:50AM +0800, Lei HH Li wrote: > Changes since V2 > - Implement the Python binding support for setting blkio throttling. > - Implement --current --live --config options support to unify the libvirt > API. > - Add changes in docs and tests. > - Some changes suggested by Adam Litke, Eric Blake, Daniel P. Berrange. >- Change the XML schema. >- API name to virDomain{Set, Get}BlockIoTune. >- Parameters changed to make them more self-explanatory. >- virsh command name to blkdeviotune. > - And other fixups. > > Changes since V1 > - Implement the support to get the block io throttling for >a device as read only connection - QMP/HMP. > - Split virDomainBlockIoThrottle into two separate functions > virDomainSetBlockIoThrottle - Set block I/O limits for a device > - Requires a connection in 'write' mode. > - Limits (info) structure passed as an input parameter > virDomainGetBlockIoThrottle - Get the current block I/O limits for a > device > - Works on a read-only connection. > - Current limits are written to the output parameter (reply). > - And Other fixups suggested by Adam Litke, Daniel P. Berrange. >- For dynamically allocate the blkiothrottle struct, I will fix > it when implement --current --live --config options support. > > Today libvirt supports the cgroups blkio-controller, which handles > proportional shares and throughput/iops limits on host block devices. > blkio-controller does not support network file systems (NFS) or other > QEMU remote block drivers (curl, Ceph/rbd, sheepdog) since they are > not host block devices. QEMU I/O throttling works with all types of > drive and can be applied independently to each drive attached to > a guest and supports throughput/iops limits. > > To help add QEMU I/O throttling support to libvirt, we plan to complete > it with add new API virDomain{Set, Get}BlockIoThrottle(), new command > 'blkdeviotune' > and Python bindings. > > Notes: Now all the planed features were implemented (#1#2 were implemented by > Zhi Yong Wu), the previous comments were all fixed up too. And the qemu part > patches > have been accepted upstream just now and are expected to be part of the QEMU > 1.1 > release, git tree from Zhi Yong: > > http://repo.or.cz/w/qemu/kevin.git/shortlog/refs/heads/block > > > 1) Enable the blkio throttling in xml when guest is starting up. > > Add blkio throttling in xml as follows: > > > ... > > nnn > ... > > ... > > > 2) Enable blkio throttling setting at guest running time. > > virsh blkdeviotune [--total_bytes_sec] > [--read_bytes_sec] \ > [--write_bytes_sec] [--total_iops_sec] > [--read_iops_sec] > [--write_iops_sec] > > 3) The support to get the current block i/o throttling for a device - HMP/QMP. > > virsh blkiothrottle > total_bytes_sec: > read_bytes_sec: > write_bytes_sec: > total_iops_sec: > read_iops_sec: > write_iops_sec: > > 4) Python binding support for setting blkio throttling. > 5) --current --live --config options support to unify the libvirt API. > > virsh blkdeviotune [--total_bytes_sec ] > [--read_bytes_sec ] > [--write_bytes_sec ] [--total_iops_sec ] [--read_iops_sec > ] > [--write_iops_sec ] [--config] [--live] [--current] > > > > daemon/remote.c | 87 +++ > docs/formatdomain.html.in | 30 ++ > docs/schemas/domaincommon.rng | 24 + > include/libvirt/libvirt.h.in | 25 ++ > python/generator.py |2 > python/libvirt-override-api.xml | 16 + > python/libvirt-override.c | 85 +++ > src/conf/domain_conf.c| 101 > src/conf/domain_conf.h| 12 > src/driver.h | 18 + > src/libvirt.c | 115 + > src/libvirt_public.syms |2 > src/qemu/qemu_command.c | 33 ++ > src/qemu/qemu_driver.c| 217 > ++ > src/qemu/qemu_monitor.c | 36 ++ > src/qemu/qemu_monitor.h | 10 > src/qemu/qemu_monitor_json.c | 191 +++ > src/qemu/qemu_monitor_json.h
Re: [libvirt] [RFC PATCH 0/8 v3] Summary on block IO throttle
On 11/10/2011 02:50 PM, Adam Litke wrote: Hi Lei, I've tested this and found that it works well except for one small thing. When the domain is running and I change one of the throttle settings using the --config option in virsh, the on-disk domain xml file is properly updated, but the command 'virsh dumpxml' returns the old version. Is this how it is supposed to work? Yes: virsh blkdeviotune --config => on-disk only (takes effect next boot; fails if transient) virsh blkdeviotune --live => running only (takes effect now, and lost on next boot; fails if offline persistent) virsh blkdeviotune --config --live => on-disk and current (takes effect now and persists to next boot; fails if not running persistent) virsh blkdeviotune --current => either --config or --live Also, in thinking about this, I can't help wonder if for extensibility of ALL the virTypedParameter commands, we might be better off with exposing a long-hand option for raw control of virTypedParameter, so that an older virsh can still set options in a newer server without having to recompile virsh to add a new named option to match every new hypervisor named option. Something like: virsh blkdeviotune --set-long total_bytes_sec=number as long-hand for: virsh blkdeviotune --total_bytes_sec number We still need a v4 respinning this to use virTypedParameter; I can help by posting a patch 1/8 that shows the changes that I think we need in the public interface, but I don't want to spend the time rebasing the entire series. -- Eric Blake ebl...@redhat.com+1-801-349-2682 Libvirt virtualization library http://libvirt.org -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list