Commit Graph
304 Commits
Author SHA1 Message Date
Gianni Tedesco 9becdd8ee9 libxl: Check whether a PCI device is assignable before assigning it do a domU
Implement a new libxl function libxl_device_pci_list_assignable. This is
used to implement the xl list-assignable-pci-devices command and part of
the implementation is used to make sure that PCI devices are not multiply
assigned to one or more domU's before doing the passthrough assignment.

The function libxl_device_pci_list changes to libxl_device_pci_list_assigned
due to a parameter change for consistency with pci_list_assignable.

Signed-off-by: Gianni Tedesco <gianni.tedesco@citrix.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
2010-07-29 18:52:33 +01:00
Gianni Tedesco a1d3c13679 libxl: Move libxl_device_pci_reset to libxl_pci.c
Signed-off-by: Gianni Tedesco <gianni.tedesco@citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
2010-07-29 18:49:47 +01:00
Christoph Egger 47aa247c1f libxl: Portability fixes for pty handling, in libxl_osdeps.h
This is the same approach used in tools/console, although we have a
separate instance of it as it is difficult to share code between these
two places.

Also add a missing include of <termios.h>, and fix a literal use of
-lutil to refer to UTIL_LIBS.

Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
2010-07-29 16:12:50 +01:00
Ian Campbell 64de62a14e Subject: xl: log unknown domain shutdown reason and default to destroy
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Christoph Egger <Christoph.Egger@amd.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
2010-07-29 15:56:13 +01:00
Ian Campbell 528ad3b6e2 libxl: consistently use typedef struct {} libxl_$type
typedef struct seems to be the dominant idiom in the mixture currently
in use.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
2010-07-28 16:18:44 +01:00
Gianni Tedesco 891c9ebad7 libxl: Move PCI specific functions to libxl_pci.c
Signed-off-by: Gianni Tedesco <gianni.tedesco@citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
2010-07-27 18:09:22 +01:00
Christoph Egger 5251ba6542 libxl: const-correctness fix to device_physdisk_major_minor
device_physdisk_major_minor does not intend to modify physpath.

Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
2010-07-27 17:55:20 +01:00
Ian Campbell c025c18b4c xl: simplify configuration parsing with local variables
Replace repeated patterns of "d_config->THING[d_config->num_THING]"
with a single local variable.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
2010-07-27 17:20:23 +01:00
Ian Campbell 49930c8b3c xl: move device structs into struct domain_config
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
2010-07-27 17:17:09 +01:00
Ian Campbell 441c97a04c xl: move create and build info to struct domain_config
All three are passed around together and this begins to reduce some of
the exceptionally long parameter lists.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
2010-07-27 17:09:11 +01:00
Ian Campbell a3dab8d97e xl: implement "rename-restart" action for shutdown
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
2010-07-27 17:08:11 +01:00
Ian Campbell 25747d176f libxl: add libxl_domain_preserve
This method is intended to preserve an existing (but shut down) domain
(for debugging purposes) in such a way that the domain can also be
restarted.

There is likely to be more required to achieve this aim than the
function currently does.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
2010-07-27 17:07:22 +01:00
Ian Campbell 1a0e17891f xl: support on_{poweroff,reboot,crash} domain configuration options.
Adds on_watchdog compared to xend.

I have further plans for struct domain_config so it isn't as pointless
as it first looks.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
2010-07-27 17:06:14 +01:00
Ian Campbell 0e89a4cedf xl: Factor out domain death handling into a separate function.
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
2010-07-27 17:05:12 +01:00
Ian Campbell 8595964bd0 xl: Add function to generate random uuid and use it.
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
2010-07-27 16:59:14 +01:00
Ian Campbell 5213606b56 libxl: signal caller if domain already destroyed on domain death event
Currently libxl_event_get_domain_death_info returns 0 if the event was
not a domain death event and 1 if it was but does not infom the user
if someone else has already cleaned up the domain, which means the
caller must replicate some of the logic from within libxl.

Instead have the libxl_event_get_XXX_info functions required that the
event is of the right type (the caller must have recently switched on
event->type anyway).

This allows the return codes to be used in an event specific way and
we take advantage of this by returning an error from
libxl_event_get_domain_death_info if the domain is not dying.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
2010-07-27 16:58:51 +01:00
Ian Campbell 1e01a066eb libxl: return libxl_dominfo from libxl_event_get_domain_death_info
Removes a libxc data type from the libxl interface.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
2010-07-27 16:58:26 +01:00
Ian Campbell 4d70c9c556 libxl: add shutdown reason to libxl_dominfo
Removes the need for explicit libxl_dominfo.crashed so remove it.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
2010-07-27 16:57:38 +01:00
Ian Campbell 8b30395218 libxl: Add LIBXL_EVENT namespace prefix to enum libxl_event_type
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
2010-07-27 16:57:06 +01:00
Gianni Tedesco 646e4efe01 libxl: fix segfault when detaching non-existant disk
Signed-off-by: Gianni Tedesco <gianni.tedesco@citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
2010-07-27 16:23:04 +01:00
Ian Jackson a438f9140a tools/libxl: Revert broken NetBSD portability patches
Revert
 df9d8319bd37 Fix blktap2 NetBSD build and also revert broken change
 e76befc7fe2d portability fixes from tools/console
 24277e3237ca Fix linking error when creating the xl binary.

Now it builds again.
2010-07-23 19:13:29 +01:00
Ian Jackson c8f6739e2e xl: Fix build after info1,info2 change
3cdba275e8c0 missed one instance, now fixed.
2010-07-23 18:50:30 +01:00
Ian Campbell e6075f0689 xl: do not try and auto re-connect console on reboot
It is not possible to run the console client if we are rebooting a
guest via the backgrounded xl process so we may as well turn off
console autoconnect after the first boot.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
2010-07-23 18:12:42 +01:00
Ian Campbell 45e70f79e1 xl: use more descriptive names than info1 and info2
c_info and b_info appears to be the common idiom in other bits of xl.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
2010-07-23 18:11:03 +01:00
Ian Campbell 71fa50d138 xl: Spelling fix to ("quite" => "quiet")
s/quite/quiet/g

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
2010-07-23 18:09:28 +01:00
Ian Campbell 5ba1a57d44 libxl/xl: correctly report domain state.
In particular distinguish between domain shutdown and crash and the
blocked and running states.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
2010-07-23 17:39:32 +01:00
Ian Campbell b5c9cd5e87 libxl: do not create /vss and /xapi paths in xenstore.
libxl doesn't know anything about these paths and there is no reason
it needs to manage them.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
2010-07-23 17:35:59 +01:00
Gianni Tedesco 2bdc928237 libxl: consistent handling of libxc errors
Lots of places in libxl return -1 as an error which is inconsistent with
libxl error codes since that is ERROR_VERSION.  Also in other places the
xc_* function to implement a command is called but the return value is
either never checked or not passed on.

This patch makes callers of libxc functions use XL_LOG_ERRNO to log a
suitable message including the contents of errno, before returning
ERROR_FAIL, if an xc call fails.  (Except for pci device removals and
domain destroys where release of resources ought to continue even if
an error occurs in an early step. In this case the error is still
logged at least.)

Also a bug is fixed where a caller depends on errno being set but is
cleared by cleanup code which calls in to library functions which modify
errno as a side-effect.


This is version 2 of the patch previously applied as 91c486918e02.
Changed since then: Removed mapping from libxc error codes to libxl -
this is redundant because libxl ought to return -1 with errno set to a
meaningful value.


Signed-off-by: Gianni Tedesco <gianni.tedesco@citrix.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
2010-07-23 17:26:28 +01:00
Ian Campbell b545cf4fb2 libxl: remove xenstore /local/domain/<domid> after reading /vm and /vss paths
On domain destroy libxl currently tries to find the /vm/<uuid> and
/vss/<uuid> paths by reading /local/domain/<domid>/{vm,vss} but does
so after removing /local/domain/<domid> which isn't much use.

Also construct the xenstore path in destroy the same way as in create. It's not
wrong but I had to look twice to check they were doing the same thing.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
2010-07-23 17:06:16 +01:00
Stefano Stabellini 8e1c320660 tools/libxl: usbdevice should imply usb
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
2010-07-23 16:58:35 +01:00
Christoph Egger 667c40e2f7 tools/libxl: Fix blktap2 NetBSD build and also revert broken change
Fix e76befc7fe2d which broke the build.
Also revert 24277e3237ca which was broken.

Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
2010-07-23 16:46:59 +01:00
Ian Jackson 389da317e2 Revert 91c486918e02 "More consistent error handling in libxl"
I'm afraid this pattern is wrong for two reasons.  Firstly,
xc_domain_pause and functions like it do not return XC_ERROR_* values.
They typically return -1 on error, and set errno.

Secondly, the error codes from libxc are not really all that useful.
They mostly serve to identify where the error originated.

See the comment in xenctrl.h near line 70.
2010-07-21 16:50:15 +01:00
Stefano Stabellini 7c8f63d3d0 Attached patch fixes linking error when creating the xl binary.
The xl binary compiles in xl_cmdimpl.c which calls code from
libxl_paths.c and libxl_bootloader.c.

Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
2010-07-20 17:37:09 +01:00
Stefano Stabellini 5db6016998 Attached patch takes over some portability fixes from tools/console
to make libxl build on NetBSD.

blktapctl is build on Linux only. This will be another patch to finally
unbreak libxl.

Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
2010-07-20 17:26:38 +01:00
Stefano Stabellini 5d7dda7847 implement xl vncviewer
Implement xl vncviewer. The only difference from xm vncviewer is that we
obey the VNCVIEWER environment variable.

Signed-off-by: Gianni Tedesco <gianni.tedesco@citrix.com>
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
2010-07-20 17:22:14 +01:00
Stefano Stabellini 965936bc90 More consistent error handling in libxl
Lots of places in libxl return -1 as an error which is inconsistent with
libxl error codes since that is ERROR_VERSION. Also in other places the
xc_* function to implement a command is called but the return value is
either never checked or not passed on.

This patch introduces a new internal function libxl_xc_error() which
maps xc error codes to xl error codes. Callers of libxc functions are
converted to use this when returning error codes back to libxl callers.

Also a bug is fixed where a caller depends on errno being set but is
cleared by cleanup code which calls in to library functions which modify
errno as a side-effect.

Signed-off-by: Gianni Tedesco <gianni.tedesco@citrix.com>
2010-07-19 18:40:09 +01:00
Stefano Stabellini a9c189d680 Implement xl dump-core
Implements dump-core command which is similar to xm dump-core except
that it requires an additional argument which is the target filename.

Signed-off-by: Gianni Tedesco <gianni.tedesco@citrix.com>
2010-07-19 15:33:38 +01:00
Stefano Stabellini 9fc200ae85 make libxl build since 21811
First hunk, I assume is getting the arguments in wrong order on memset.

Second hunk is to kill a compiler warning about mis-use of printf-style
format strings which kills the build on -Werror.

Signed-off-by: Gianni Tedesco <gianni.tedesco@citrix.com>
2010-07-19 15:15:32 +01:00
Stefano Stabellini 402ddf4b39 This patch introduces libxl_primary_console_exec: a new libxl function
that finds the domid and console number corresponding to the primary
console of a given vm. The domid might be different from the domid of
the VM and the console number might not be 0 when using stubdoms.
The caller (xl_cmdimpl.c in this case) has to make sure that the stubdom
is already created before calling libxl_primary_console_exec in the hvm
case. In the PV case libxl_primary_console_exec has to be called before
libxl_run_bootloader.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
2010-07-19 12:47:53 +01:00
Stefano Stabellini 6b331584fb execute command by execvp() so can search command in PATH.
Signed-off-by: Yu Zhiguo <yuzg@cn.fujitsu.com>
2010-07-19 12:22:25 +01:00
Stefano Stabellini 870648146f Implement "xl tmem-freeable" to match "xm tmem-freeable".
Signed-off-by: Dan Magenheimer <dan.magenheimer@oracle.com>
2010-07-19 12:20:41 +01:00
Ian Jackson 214abecaa3 xl: start numbering vifs from 0
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
2010-07-14 16:46:49 +01:00
Ian Jackson 6a8f8977a1 libxl, xl: support running bootloader (e.g. pygrub) in domain 0
Much of the bootloader interaction (including the Solaris and NetBSD
portability bits) are translated pretty much directly from the python
in tools/python/xen/xend/XendBootloader.py

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
2010-07-14 16:45:38 +01:00
Ian Jackson 2587d9aa4e libxl: add function to attach/detach a disk to/from the local VM
Useful if you need to read a guest filesystem (e.g. pygrub).

I'm not overly thrilled with the implementation WRT tap interfaces,
particularly WRT to detach. I was unable to find a way to get at the
paramters necessary to call tap_ctl_destroy so I assumed for now it
that is OK to assume that the tap device is going to be wanted for the
actual domain at some point in the immediate future and hence there is
no pressing need to destroy it.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
2010-07-14 16:44:18 +01:00
Ian Jackson 108be15853 libxl: support mapping files rather than carrying paths around
This will allow us to map and then unlink the file and therefore
delete the process on process exit or explicit unmap.

Using the mmaped versions of these files required rewriting build_pv
to use the xc_dom builder functionality directly rather than through
the xc_linux_build "compatibility layer". (The status of the
xc_linux_build interface as a compatibility layer seems a bit dubious
since all existing callers use it but if anything is going to replace
it then libxl seems like the likely candidate).

I'm not thrilled with the definition of the maps lifecycle. This could
be solved by adding a helper function to explicitly free the toplevel
structure.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
2010-07-14 16:43:49 +01:00
Ian Jackson adb8dd8440 libxl, xl: exec xenconsole in current process, defer decision to fork to caller
Use this to run xenconsole as the foreground process and move the
connection to the console in the "create -c" case early enough to be
able to view output from the bootloader. This behaviour is consistent
with how both "xm console" and "xm create -c" operate.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
2010-07-14 16:40:33 +01:00
Ian Jackson df9760236b libxl: fix typo in comment
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
2010-07-14 16:40:09 +01:00
Ian Jackson bba3b1da6e libxl: add libxl_strdup convenience function
Use in preference to libxl_sprintf(..., "%s", "...")

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
2010-07-14 16:39:43 +01:00
Ian Jackson 1304d52120 libxl: add printf attribute to libxl_xs_write and fixup resulting warnings
There is an unfortunate warning for the empty format string by default
which I workaround by adding -Wno-format-zero-length.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
2010-07-14 16:38:47 +01:00
Ian Jackson 85bd32d908 xl: default timer_mode to 1
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
2010-07-14 16:31:59 +01:00