aboutsummaryrefslogtreecommitdiffstats
path: root/tools/libxl
Commit message (Collapse)AuthorAgeFilesLines
* libxl: fix out-of-memory error handling in libxl_list_cpupoolstable-4.2Matthew Daley2013-10-101-0/+1
| | | | | | | | | | | | | | ...otherwise it will return freed memory. All the current users of this function check already for a NULL return, so use that. Coverity-ID: 1056194 This is CVE-2013-4371 / XSA-70 Signed-off-by: Matthew Daley <mattjd@gmail.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> (cherry picked from commit 4c37ed562224295c0f8b00211287d57cae629782) (cherry picked from commit 2350e70ee06c903a927340f7a0bf9ca25acce3f3)
* libxl: fix vif rate parsingIan Jackson2013-10-102-6/+17
| | | | | | | | | | | | | | | | | strtok can return NULL here. We don't need to use strtok anyway, so just use a simple strchr method. Coverity-ID: 1055642 This is CVE-2013-4369 / XSA-68 Signed-off-by: Matthew Daley <mattjd@gmail.com> Fix type. Add test case Signed-off-by: Ian Campbell <Ian.campbell@citrix.com> (cherry picked from commit c53702cee1d6f9f1b72f0cae0b412e21bcda8724) (cherry picked from commit 60aefd150bc0ad0c7d325da5ffea0bf4e0544130)
* Fix issue with 'xl list -l' showing domids as -1 when using SXPIan Murray2013-07-121-1/+1
| | | | | | | | | | | | | | During investigation of other issues, it came to light that in at least 4.2.2, "xl list -l" displays domain ids as -1 when using SXP, irrespective of actual value. Ian C identified that this issue was likely fixed in the upcoming 4.3 release but the commit responsible for the fix (a73a7a0c647a9a5e30d8bc473c0a1e8648817183) was not likely a candidate for backporting in its entirety. Therefore, this patch is just an isolation of the hunk to fix the above issue. Original Commit Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Backport Created-by: Ian Murray <murrayie@yahoo.co.uk>
* libxl_json: Fix backport of JSON_BOOL to 4.2.2Don Slutz2013-07-121-0/+1
| | | | | | | | | | | | | | git commit 2b3072ed0cbeed8c0385f20e92ba0f1201db8a17 ('libxl_json: Replace JSON_TRUE/FALSE by JSON_BOOL.') has the setting of obj->u.b git commit 6a2aca9fdef0499e613715baf107f2296b9007cf ('libxl_json: Replace JSON_TRUE/FALSE by JSON_BOOL.') does not. This shows up by vnc-port and vnc-listen are missing in xenstore when they should not be. Signed-off-by: Don Slutz <dslutz@verizon.com> Acked-By: Alex Bligh <alex@alex.org.uk>
* libxl: suppress device assignment to HVM guest when there is no IOMMUJan Beulich2013-07-091-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | This in effect copies similar logic from xend: While there's no way to check whether a device is assigned to a particular guest, XEN_DOMCTL_test_assign_device at least allows checking whether an IOMMU is there and whether a device has been assign to _some_ guest. For the time being, this should be enough to cover for the missing error checking/recovery in other parts of libxl's device assignment paths. There remains a (functionality-, but not security-related) race in that the iommu should be set up earlier, but this is too risky a change for this stage of the 4.3 release. This is a security issue, XSA-61. Signed-off-by: Jan Beulich <jbeulich@suse.com> Tested-by: George Dunlap <george.dunlap@eu.citrix.com> Acked-by: George Dunlap <george.dunlap@eu.citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> master commit: 826eb17271d3c647516d9944c47b0779afedea25 master date: 2013-07-01 15:20:28 +0100
* libxl: Restrict permissions on PV console device xenstore nodesIan Jackson2013-06-275-34/+80
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Matthew Daley has observed that the PV console protocol places sensitive host state into a guest writeable xenstore locations, this includes: - The pty used to communicate between the console backend daemon and its client, allowing the guest administrator to read and write arbitrary host files. - The output file, allowing the guest administrator to write arbitrary host files or to target arbitrary qemu chardevs which include sockets, udp, ptr, pipes etc (see -chardev in qemu(1) for a more complete list). - The maximum buffer size, allowing the guest administrator to consume more resources than the host administrator has configured. - The backend to use (qemu vs xenconsoled), potentially allowing the guest administrator to confuse host software. So we arrange to make the sensitive keys in the xenstore frontend directory read only for the guest. This is safe since the xenstore permissions model, unlike POSIX directory permissions, does not allow the guest to remove and recreate a node if it has write access to the containing directory. There are a few associated wrinkles: - The primary PV console is "special". It's xenstore node is not under the usual /devices/ subtree and it does not use the customary xenstore state machine protocol. Unfortunately its directory is used for other things, including the vnc-port node, which we do not want the guest to be able to write to. Rather than trying to track down all the possible secondary uses of this directory just make it r/o to the guest. All newly created subdirectories inherit these permissions and so are now safe by default. - The other serial consoles do use the customary xenstore state machine and therefore need write access to at least the "protocol" and "state" nodes, however they may also want to use arbitrary "feature-foo" nodes (although I'm not aware of any) and therefore we cannot simply lock down the entire frontend directory. Instead we add support to libxl__device_generic_add for frontend keys which are explicitly read only and use that to lock down the sensitive keys. - Minios' console frontend wants to write the "type" node, which it has no business doing since this is a host/toolstack level decision. This fails now that the node has become read only to the PV guest. Since the toolstack already writes this node just remove the attempt to set it. This is CVE-2013-2211 / XSA-57 Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Conflicts: tools/libxl/libxl.c (no vtpm, free front_ro on error in libxl__device_console_add)
* libxl: Fix SEGV in network-attachIan Jackson2013-04-181-1/+2
| | | | | | | | | When "device/vif" directory exists but is empty l!=NULL, but nb==0, so l[nb-1] is invalid. Add missing check. Signed-off-by: Marek Marczykowski <marmarek@invisiblethingslab.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
* x86: fix various issues with handling guest IRQsJan Beulich2013-04-181-5/+7
| | | | | | | | | | | | | | | - properly revoke IRQ access in map_domain_pirq() error path - don't permit replacing an in use IRQ - don't accept inputs in the GSI range for MAP_PIRQ_TYPE_MSI - track IRQ access permission in host IRQ terms, not guest IRQ ones (and with that, also disallow Dom0 access to IRQ0) This is CVE-2013-1919 / XSA-46. Signed-off-by: Jan Beulich <jbeulich@suse.com> Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> master commit: 545607eb3cfeb2abf5742d1bb869734f317fcfe5 master date: 2013-04-18 16:11:23 +0200
* libxl: don't launch more than one tapdisk process for each diskIan Jackson2013-04-151-7/+10
| | | | | | | | | | | | | | | | | When adding a disk don't launch multiple tapdisk instances for the same disk, if transaction fails in device_disk_add reuse the same tapdisk for further tries instead of creating a new instance each time a transaction fails. Reported-by: Darren Shepherd <darren.s.shepherd@gmail.com> Signed-off-by: Roger Pau Monne <roger.pau@citrix.com> Tested-by: Darren Shepherd <darren.s.shepherd@gmail.com> Backport-requested-by: Pasi Karkkainen <pasik@iki.fi> (cherry picked from commit ec398660e89ca18bb8d061d5047d682bd383778a) Conflicts: tools/libxl/libxl.c Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
* libxl: run libxl__arch_domain_create() much earlier.Ian Jackson2013-04-094-11/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Among other things, arch_domain_create() sets the shadow(/hap/p2m) memory allocation, which must happen after vcpus are assigned (or the shadow op will fail) but before memory is allocated (or we might run out of p2m memory). libxl__build_pre(), which already sets similar things like maxmem, semes like a reasonable spot for it. That needed a bit of plumbing to get the right datastructure from the caller. As a side-effect, the return code from libxl__arch_domain_create() is no longer ignored. This bug was analysed in: From: "Jan Beulich" <JBeulich@xxxxxxxx> "Re: [Xen-devel] [xen-unstable test] 16788: regressions - FAIL" Date: Mon, 04 Mar 2013 16:34:53 +0000 http://lists.xen.org/archives/html/xen-devel/2013-03/msg00191.html Reported-by: Jan Beulich <JBeulich@suse.com> Signed-off-by: Tim Deegan <tim@xen.org> Cc: Ian Jackson <ian.jackson@eu.citrix.com> Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com> Cc: Ian Campbell <ian.campbell@citrix.com> (Cherry-picked from 650354dbc2626b643c12873275ca67782f1382c8.) Conflicts: tools/libxl/libxl_dom.c Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
* tools/libxl: Improve videoram settingFabio Fantoni2013-03-042-2/+24
| | | | | | | | | | | | | | | | | | | - If videoram setting is less than 8 mb shows error and exit. - Added videoram setting for qemu upstream with cirrus (added in qemu 1.3). - Updated xl.cfg man. - Default and minimal videoram changed to 16 mb if stdvga is set and upstream qemu is being used. This is required by qemu 1.4 to avoid a xen memory error (qemu 1.3 doesn't complain about it, probably buggy). Signed-off-by: Fabio Fantoni <fabio.fantoni@heliman.it> Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com> Cherry picked from xen-unstable 2e814a017155b885e4d4b5a88dc05e7367a9722a, backport as follows: Signed-off-by: Fabio Fantoni <fabio.fantoni@heliman.it> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
* tools: Fix memset(&p,0,sizeof(p)) idiom in several places.Michael Young2013-02-281-1/+1
| | | | | | | | | | gcc 4.8 identifies several places where code of the form memset(x, 0, sizeof(x)); is used incorrectly, meaning that less memory is set to zero than required. Signed-off-by: Michael Young <m.a.young@durham.ac.uk> Committed-by: Keir Fraser <keir@xen.org> (cherry picked from commit d119301b5816b39b5ba722a2f8b301b37e8e34bd)
* libxl: fix stale timeout event callback raceIan Jackson2013-02-222-77/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Because there is not necessarily any lock held at the point the application (eg, libvirt) calls libxl_osevent_occurred_timeout, in a multithreaded program those calls may be arbitrarily delayed in relation to other activities within the program. Specifically this means when ->timeout_deregister returns, libxl does not know whether it can safely dispose of the for_libxl value or whether it needs to retain it in case of an in-progress call to _occurred_timeout. The interface could be fixed by requiring the application to make a new call into libxl to say that the deregistration was complete. However that new call would have to be threaded through the application's event loop; this is complicated and some application authors are likely not to implement it properly. Furthermore the easiest way to implement this facility in most event loops is to queue up a time event for "now". Shortcut all of this by having libxl always call timeout_modify setting abs={0,0} (ie, ASAP) instead of timeout_deregister. This will cause the application to call _occurred_timeout. When processing this calldown we see that we were no longer actually interested and simply throw it away. Additionally, there is a race between _occurred_timeout and ->timeout_modify. If libxl ever adjusts the deadline for a timeout the application may already be in the process of calling _occurred, in which case the situation with for_app's lifetime becomes very complicated. Therefore abolish libxl__ev_time_modify_{abs,rel} (which have no callers) and promise to the application only ever to call ->timeout_modify with abs=={0,0}. The application still needs to cope with ->timeout_modify racing with its internal function which calls _occurred_timeout. Document this. This is a forwards-compatible change for applications using the libxl API, and will hopefully eliminate these races in callback-supplying applications (such as libvirt) without the need for corresponding changes to the application. (It is possible that this might expose bugs in applications, though, as previously libxl would never call libxl_osevent_hooks->timeout_modify and now it never calls ->timeout_deregister). For clarity, fold the body of time_register_finite into its one remaining call site. This makes the semantics of ev->infinite slightly clearer. Cc: Bamvor Jian Zhang <bjzhang@suse.com> Cc: Ian Campbell <Ian.Campbell@citrix.com> Tested-by: Jim Fehlig <jfehlig@suse.com> Acked-by: Jim Fehlig <jfehlig@suse.com> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
* libxl: fix stale fd event callback raceIan Jackson2013-02-222-29/+163
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Because there is not necessarily any lock held at the point the application (eg, libvirt) calls libxl_osevent_occurred_timeout and ..._fd, in a multithreaded program those calls may be arbitrarily delayed in relation to other activities within the program. libxl therefore needs to be prepared to receive very old event callbacks. Arrange for this to be the case for fd callbacks. This requires a new layer of indirection through a "hook nexus" struct which can outlive the libxl__ev_foo. Allocation and deallocation of these nexi is mostly handled in the OSEVENT macros which wrap up the application's callbacks. Document the problem and the solution in a comment in libxl_event.c just before the definition of struct libxl__osevent_hook_nexus. There is still a race relating to libxl__osevent_occurred_timeout; this will be addressed in the following patch. Reported-by: Bamvor Jian Zhang <bjzhang@suse.com> Cc: Bamvor Jian Zhang <bjzhang@suse.com> Cc: Ian Campbell <Ian.Campbell@citrix.com> Tested-by: Jim Fehlig <jfehlig@suse.com> Acked-by: Jim Fehlig <jfehlig@suse.com> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Backport-requested-by: Stefano Stabellini <Stefano.Stabellini@eu.citrix.com> Backported-by: Ian Jackson <ian.jackson@eu.citrix.com> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
* libxl: rename "abs" variables to "absolute"Ian Jackson2013-02-221-17/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | No functional change. The purpose is to make it easier to backport patches from Xen 4.3's libxl, as Xen 4.3's libxl has had this done: libxl: Enable -Wshadow. It was convenient to invent $(CFLAGS_LIBXL) to do this. Various renamings to avoid shadowing standard functions: - index(3) - listen(2) - link(2) - abort(3) - abs(3) Signed-off-by: Ian Campbell <ian.campbell@citrix.com> In this patch we do not change the others, and we do not enable -Wshadow. We're just trying to bring 4.2's libxl textually closer to 4.3's. Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
* libxl: Allow migration with qemu-xen.Alex Bligh2013-02-191-17/+0
| | | | | | | | | | | Backport of xen-unstable patch: : HG changeset patch : User Anthony PERARD <anthony.perard@citrix.com> : Date 1349693136 -3600 : Node ID 0995890022391682a2499a202c3c8608e1d3780a : Parent 08fac5c2bf3dcbc493ce45091383f6ce1938f369 Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
* libxl: libxl__qmp_save: Add filename as JSON parameter to ↵Alex Bligh2013-02-191-0/+1
| | | | | | xen-save-devices-state Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
* libxl_dom: Call the right switch logdirty for the right DM.Alex Bligh2013-02-191-3/+42
| | | | | | | | | | | | | | | | | This patch dispatch the switch logdirty call depending on which device model version is running. The call to qemu-xen right now is synchronous, not like the one to qemu-xen-traditional. Backport of xen-unstable patch: : HG changeset patch : User Anthony PERARD <anthony.perard@citrix.com> : Date 1349693136 -3600 : Node ID 08fac5c2bf3dcbc493ce45091383f6ce1938f369 : Parent d4aec9eff7e6d15c2805957af620c82555553b3e Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
* libxl_qmp: Introduce libxl__qmp_set_global_dirty_log.Alex Bligh2013-02-192-2/+12
| | | | | | | | | | | | | | This function will enable or disable the global dirty log on QEMU, used during a migration. Backport of xen-unstable patch: : HG changeset patch : User Anthony PERARD <anthony.perard@citrix.com> : Date 1349693135 -3600 : Node ID d4aec9eff7e6d15c2805957af620c82555553b3e : Parent f3890916496445c97d6778d6c986b0270ff707f2 Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
* libxl_qmp: Simplify run of single QMP commands.Alex Bligh2013-02-191-55/+22
| | | | | | | | | | | | | This new function connects to QEMU, sends the command and disconnects. Backport of xen-unstable patch: : HG changeset patch : User Anthony PERARD <anthony.perard@citrix.com> : Date 1349693134 -3600 : Node ID f3890916496445c97d6778d6c986b0270ff707f2 : Parent be5d014f91dfbd67afacc3385c265243794a246f Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
* libxl_qmp: Use qmp_parameters_* functions for param list of a QMP command.Alex Bligh2013-02-191-59/+30
| | | | | | | | | | | Backported from xen-unstable patch: : HG changeset patch : User Anthony PERARD <anthony.perard@citrix.com> : Date 1349693133 -3600 : Node ID be5d014f91dfbd67afacc3385c265243794a246f : Parent 6f7847729f0f42614de516d15257ede7243f995f Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
* libxl_qmp: Introduces helpers to create an argument list.Alex Bligh2013-02-191-0/+51
| | | | | | | | | | | | | | | | | | Those functions will be used to create a "list" of parameters that contain more than just strings. This list is converted by qmp_send to a string to be sent to QEMU. Those functions will be used in the next two patches, so right now there are not compiled. Backported from xen-unstable patch: : HG changeset patch : User Anthony PERARD <anthony.perard@citrix.com> : Date 1349693132 -3600 : Node ID 6f7847729f0f42614de516d15257ede7243f995f : Parent 74dee58cfc0d2d6594f388db3b4d2ce91d1bb204 Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
* libxl_json: Introduce libxl__json_object_to_yajl_gen.Alex Bligh2013-02-192-0/+64
| | | | | | | | | | | | | | | | | | | This function converts a libxl__json_object to yajl by calling every yajl_gen_* function on a preallocated yajl_gen hand. This helps to integrate a json_object into an already existing yajl_gen tree. This function is used in a later patch. Backported from xen-unstable patch: : HG changeset patch : User Anthony PERARD <anthony.perard@citrix.com> : Date 1349693132 -3600 : Node ID 74dee58cfc0d2d6594f388db3b4d2ce91d1bb204 : Parent 3f71aab0e2774ded0c5a03436c364fb031ba9aa0 Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
* libxl_json: Replace JSON_TRUE/FALSE by JSON_BOOL.Alex Bligh2013-02-193-5/+16
| | | | | | | | | | | | | | Those two JSON_TRUE and JSON_FALSE were types of node. But it's better to have a unique JSON_BOOL type. Backported from xen-unstable patch: : HG changeset patch : User Anthony PERARD <anthony.perard@citrix.com> : Date 1349693131 -3600 : Node ID 3f71aab0e2774ded0c5a03436c364fb031ba9aa0 : Parent 4a6d5d8cba4fc44f9bbda201188885868604b8e8 Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
* libxl_json: Remove JSON_ERROR from enum.Alex Bligh2013-02-191-1/+0
| | | | | | | | | | | | | This value from libxl__json_node_type is never used. Backported from xen-unstable patch: : HG changeset patch : User Anthony PERARD <anthony.perard@citrix.com> : Date 1349693130 -3600 : Node ID 4a6d5d8cba4fc44f9bbda201188885868604b8e8 : Parent c9b80c7f8db1a5d26906a2298c481bf7e87fda94 Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
* libxl_json: Export json_object related function.Alex Bligh2013-02-192-18/+28
| | | | | | | | | | | | | Export libxl__json_object_alloc and libxl__json_object_append_to to use them in a later patch. Backported from xen-unstable patch: : User Anthony PERARD <anthony.perard@citrix.com> : Date 1349693129 -3600 : Node ID c9b80c7f8db1a5d26906a2298c481bf7e87fda94 : Parent 93e3e6a33e0a1ec9f92fc575334caa35e6dbc757 Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
* libxl: fix vfb related assertion problem when starting pv-domURonny Hegewald2012-12-131-0/+2
| | | | | | | | | | | | | | | | | | | | | | | When a config-file for a pv-domU has a vfb section with a vnc=0 option then a "xl create" for that domU crashes with the message xl: libxl.c:252: libxl_defbool_val: Assertion `!libxl_defbool_is_default(db)' failed. and the domU hangs early in the start. This patch fixes the cause of the assertion and let the domU start normally. This problem exists since xen 4.2. Signed-off-by: Ronny Hegewald <Ronny.Hegewald@online.de> Acked-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com> xen-unstable changeset: 26145:8b93ac0c93f3 Backport-requested-by: Ian Campbell <Ian.Campbell@xxxxxxxxxx> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
* libxl: fix a variable underflow in libxl_wait_for_free_memoryRonny Hegewald2012-11-291-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | When xl is called to create a domU and there is not enough memory available, then the autoballooning is called to extract memory from dom0. During the ballooning a loop in libxl_wait_for_free_memory() waits unless enough memory is available to create the domU. But because of a variable-underflow the loop can finish too soon and xl finally aborts with the message: xc: error: panic: xc_dom_boot.c:161: xc_dom_boot_mem_init: can't allocate low memory for domain: Out of memory libxl: error: libxl_dom.c:430:libxl__build_pv: xc_dom_boot_mem_init failed: Device or resource busy libxl: error: libxl_create.c:901:domcreate_rebuild_done: cannot (re-)build domain: -3 The variable-underflow happens when freemem_slack is larger then info.free_pages*4, because the solution of this operation is converted implicit to a unsigned int to match the type of memory_kb. Add a extra check for this condition to solve the problem. Signed-off-by: Ronny Hegewald <Ronny.Hegewald@online.de> Acked-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com> xen-unstable changeset: 26190:678718a2e565 Backport-requested-by: Ian Jackson <Ian.Jackson@eu.citrix.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
* xl: Suppress spurious warning message for cpupool-listGeorge Dunlap2012-11-291-1/+2
| | | | | | | | | | | | | | | | | | | | libxl_cpupool_list() enumerates the cpupools by "probing": calling cpupool_info, starting at 0 and stopping when it gets an error. However, cpupool_info will print an error when the call to xc_cpupool_getinfo() fails, resulting in every xl command that uses libxl_list_cpupool (such as cpupool-list) printing that error message spuriously. Since at the moment the times we want to print the message correspond with the use of the existing "exact" parameter, use it to decide whether to print the message or not. Signed-off-by: George Dunlap <george.dunlap@eu.citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com> xen-unstable changeset: 26185:d66987697fe3 Backport-requested-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
* libxl: Fix passing of application data to timeout_deregister hookJim Fehlig2012-11-161-1/+1
| | | | | | | | | | | | | | When deregistering a timeout, the address of application data was being passed to the timeout_deregister hook instead of the data itself. Signed-off-by: Jim Fehlig <jfehlig@suse.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com> xen-unstable changeset: 26155:babb84d9a82e Backport-requested-by: Ian Campbell <Ian.Campbell@citrix.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
* libxl: properly handle errors from page sharing hypercallsIan Jackson2012-11-011-12/+16
| | | | | | | | | | | | | 25886:051e2a30e3fb (25894:95a971c8058f in xen-unstable) is wrong because it assumes that xc_sharing_freed_pages etc. return -errnoval on error. However, like other libxc calls they return -1 setting errno. Correct this, checking for l<0 and then testing errno against ENOSYS, and also log the correct errno value. Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
* libxl: Tolerate xl config files missing trailing newlineIan Jackson2012-10-262-78/+88
| | | | | | | | | | Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com> xen-unstable changeset: 25902:28bb7ba5faf6 Backport-requested-by: Ian Campbell <Ian.Campbell@citrix.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
* libxl: propagate user supplied values into event for_user field.Ian Campbell2012-10-264-12/+15
| | | | | | | | | | | | | | This was ommited in the majority of cases. Add as a parameter to libxl__event_new and the NEW_EVENT wrapper to help prevent it being forgotten in the future. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com> xen-unstable changeset: 26089:fb5cf014b387 Backport-requested-by: Ian Campbell <Ian.Campbell@citrix.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
* libxl: ao: cope with fast ao completion with progess eventsIan Jackson2012-10-261-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There are two egcs in an ao initiator: the one in the AO_CREATE function, and the one in libxl__ao_inprogress. If synchronous ao operation generates progress events and completes immediately, the progress callbacks end up queued in the outer egc. These callbacks are currently only called after libxl__ao_inprogress has returned, and keep the ao alive until they happen. This is not good because the principle is that a synchronous ao is not supposed to survive beyond libxl__ao_inprogress's return. The fix is to ensure that the callbacks queued in the outer egc are called early enough that they don't preserve the ao. This is straightforward in the AO_INPROGRESS macro because AO_CREATE's egc is not used inside that macro other than to destroy it. All we have to do is destroy it a bit sooner. This involves unlocking and relocking the ctx since EGC_FREE expects to be called with the lock released but libxl__ao_inprogress needs it locked. This hole in our lock tenure is fine - libxl__ao_inprogress has such holes already. It is still possible to use the CTX_LOCK macros for this unlock/lock because the gc we are using is destroyed only afterwards by libxl__ao_inprogress. Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com> xen-unstable changeset: 26080:25b2f53d2583 Backport-requested-by: Ian Campbell <Ian.Campbell@citrix.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
* xl/libxl: make shutdown accept the long option --wait for -wSander Eikelenboom2012-10-262-2/+6
| | | | | | | | | | | | | Make xl/libxl accept the long option --wait for -w to be compatible with xm. The long options are used in the default init and sysconfig scripts. Signed-off-by: Sander Eikelenboom <linux@eikelenboom.it> Acked-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com> xen-unstable changeset: 26045:ba7198bfc679 Backport-requested-by: Ian Campbell <Ian.Campbell@citrix.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
* libxl/qemu-xen: use cache=writeback for IDE and SCSIStefano Stabellini2012-10-261-4/+4
| | | | | | | | | | | | | | | | | | | | Change caching mode from writethrough to writeback for upstream QEMU. After a lengthy discussion, we came up with the conclusion that WRITEBACK is OK for IDE. See: http://marc.info/?l=xen-devel&m=133311527009773 Given that the same reasons apply to SCSI as well, change to writeback for SCSI too. Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com> xen-unstable changeset: 25989:0807d1f7773d Backport-requested-by: Ian Campbell <Ian.Campbell@citrix.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
* libxl: make devid a type so it is initialized properlyMatthew Fioravante2012-10-263-6/+8
| | | | | | | | | | | | | | | | | | | | Previously device ids in libxl were treated as integers meaning they were being initialized to 0, which is a valid device id. This patch makes devid its own type in libxl and initializes it to -1, an invalid value. This fixes a bug where if you try to do a xl DEV-attach multiple time it will continuously try to reattach device 0 instead of generating a new device id. Signed-off-by: Matthew Fioravante <matthew.fioravante@jhuapl.edu> Reviewed-by: George Dunlap <george.dunlap@eu.citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com> xen-unstable changeset: 25988:8a073eb1e849 Backport-requested-by: Ian Campbell <Ian.Campbell@citrix.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
* xl: resume the domain on suspend failureBastian Blank2012-10-261-3/+6
| | | | | | | | | | | | | The MUST macro calls exit(3) on failure but we need to cleanup and resume. Signed-off-by: Bastian Blank <waldi@debian.org> Acked-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com> xen-unstable changeset: 25942:16ee1d300cfd Backport-requested-by: Ian Campbell <Ian.Campbell@citrix.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
* libxl: Fix missing dependency in api check ruleIan Jackson2012-10-261-4/+4
| | | | | | | | | | | | | | | | | | | | | Without this, the api check cpp run might happen before the various autogenerated files which are #include by libxl.h are ready. We need to remove the api-ok file from AUTOINCS to avoid a circular dependency. Instead, we list it explicitly as a dependency of the object files. The result is that the api check is the last thing to be done before make considers the preparation done and can start work on compiling .c files into .o's. Reported-by: Olaf Hering <olaf@aepfle.de> Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Tested-by: Olaf Hering <olaf@aepfle.de> Acked-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com> xen-unstable changeset: 25901:c51229d1522e Backport-requested-by: Ian Campbell <Ian.Campbell@citrix.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
* xl: error if vif backend!=0 is used with run_hotplug_scriptsRoger Pau Monne2012-10-261-0/+7
| | | | | | | | | | | | | | | | | Print an error and exit if backend!=0 is used in conjunction with run_hotplug_scripts. Currently libxl can only execute hotplug scripts from the toolstack domain (the same domain xl is running from). Added a description and workaround of this issue on xl-network-configuration. Signed-off-by: Roger Pau Monne <roger.pau@citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com> xen-unstable changeset: 25897:ff6d94944039 Backport-requested-by: Ian Campbell <Ian.Campbell@citrix.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
* libxl: fix usage of backend parameter and run_hotplug_scriptsRoger Pau Monne2012-10-261-0/+14
| | | | | | | | | | | | | | | vif interfaces allows the user to specify the domain that should run the backend (also known as driver domain) using the 'backend' parameter. This is not compatible with run_hotplug_scripts=1, since libxl can only run the hotplug scripts from the Domain 0. Signed-off-by: Roger Pau Monne <roger.pau@citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com> xen-unstable changeset: 25896:259c4e9d8adf Backport-requested-by: Ian Campbell <Ian.Campbell@citrix.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
* libxl: handle errors from xc_sharing_* info functionsIan Campbell2012-10-261-2/+19
| | | | | | | | | | | | | | | | | | | | On a 32 bit hypervisor xl info currently reports: sharing_freed_memory : 72057594037927935 sharing_used_memory : 72057594037927935 Eat the ENOSYS and turn it into 0. Log and propagate other errors. I don't have a 32 bit system handy, so tested on x86_64 with a libxc hacked to return -ENOSYS and -EINVAL. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Acked-by: Andres Lagar-Cavilla <andres@lagarcavilla.org> Committed-by: Ian Campbell <ian.campbell@citrix.com> xen-unstable changeset: 25894:95a971c8058f Backport-requested-by: Ian Campbell <Ian.Campbell@citrix.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
* libxl: fix error message in device_backend_callbackRoger Pau Monne2012-10-261-1/+2
| | | | | | | | | | | | | | device_backend_callback error path always says "unable to disconnect", but this can also happen during the connection of a device. Fix the error message using the information in aodev->action. Signed-off-by: Roger Pau Monne <roger.pau@citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com> xen-unstable changeset: 25838:2f418851f36d Backport-requested-by: Ian Campbell <Ian.Campbell@citrix.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
* tools: bump SONAMEs for changes during 4.2 development cycle.Ian Campbell2012-10-021-1/+1
| | | | | | | | | | | | | | | We mostly did this as we went along, only a couple of minor number bumps were missed http://marc.info/?l=xen-devel&m=134366054929255&w=2: - Bumped libxl from 1.0.0 -> 1.0.1 - Bumped libxenstore from 3.0.1 -> 3.0.2 Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com> xen-unstable changeset: 25943:0a64f1a3f72c Backport-requested-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
* libxl: fix api check MakefileIan Jackson2012-09-031-3/+5
| | | | | | | | | | | | | | | | | Touch the libxl.api-ok stamp file, and unconditionally put in place the new _libxl.api-for-check. This avoids needlessly rerunning the preprocessor on libxl.h each time we call "make". Ensure that _libxl.api-for-check gets the CFLAGS used for xl, so that if it is asked for in a standalone make run it can find xentoollog.h. Remove *.api-ok on clean. Also fix .gitignore. Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com>
* libxl/xl: implement support for guest ioport and irq permissions.Ian Campbell2012-09-033-1/+124
| | | | | | | | | | | | | | | | | | | | This is useful for passing legacy ISA devices (e.g. com ports, parallel ports) to guests. Supported syntax is as described in http://cmrg.fifthhorseman.net/wiki/xen#grantingaccesstoserialhardwaretoadomU I tested this using Xen's 'q' key handler which prints out the I/O port and IRQ ranges allowed for each domain. e.g.: (XEN) Rangesets belonging to domain 31: (XEN) I/O Ports { 2e8-2ef, 2f8-2ff } (XEN) Interrupts { 3, 5-6 } Signed-off-by: Ian Campbell <ian.campbell@citrix.com> Tested-by: Dieter Bloms <dieter@bloms.de> Acked-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com>
* libxl: fix double free on some config parser errorsIan Jackson2012-08-312-65/+61
| | | | | | | | | | | | | | | | | | | | | | | | | | If libxlu_cfg_y.y encountered a config file error, the code generated by bison would sometimes _both_ run the %destructor _and_ call xlu__cfg_set_store for the same XLU_ConfigSetting* semantic value. The result would be a double free. This appears to be because of the use of a mid-rule action. There is some discussion of the problems with destructors and mid-rule action error handling in "(bison)Mid-Rule Actions". This area is complex and best avoided. So fix the bug by abolishing the use of a mid-rule action, which was in any case not necessary here. Also while we are there rename the nonterminal rule "setting" to "assignment", to avoid confusion with the token type "setting", which had an identically name in a different namespace. This was especially confusing because the nonterminal "setting" did not have "setting" as the type of its semantic value! (In fact the nonterminal, now called "assignment", does not have a value so it does not have a value type.) Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com>
* tools/xl: Fix uninitialized variable error.Andrew Cooper2012-08-281-4/+4
| | | | | | | | | | | | | | | | | | c/s 25779:4ca40e0559c3 introduced a compilation error for any build system using -Werror=uninitialized, such as the default CentOS 5.7 version of gcc. And with good reason, because if the global libxl default_output_format is neither OUTPUT_FORMAT_SXP nor OUTPUT_FORMAT_JSON, the variable hand will be used before being initialised. The attached patch fixes the warning, and futher fixes the logic to work correctly when a new OUTPUT_FORMAT is added to xl. Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> Acked-by: Ian Campbell <ian.campbell@citrix.com> Committed-by: Ian Campbell <ian.campbell@citrix.com>
* libxl: Rerun bisonIan Jackson2012-08-242-192/+241
| | | | | | | | | | | | | This updates libxlu_cfg_y.[ch] to code generated by bison from Debian squeeze (1:2.4.1.dfsg-3 i386). There should be no functional change since there is no change to the source file, but we will inherit bugfixes and behavioural changes from the new version of bison. So this is more a matter of hope than knowledge. Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
* libxl: Rerun flexIan Jackson2012-08-242-56/+40
| | | | | | | | | | This undoes some systematic changes which were made to libxlu_cfg_l.[ch] along with manually-edited files (eg, whitespace changes, emacs local variables) and returns these two files to exactly the output of flex (Debian squeeze 2.5.35-10 i386). Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com> Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>