ia64/xen-unstable
changeset 13837:fbc128aafdeb
merge with xen-unstable.hg
author | awilliam@xenbuild2.aw |
---|---|
date | Sun Feb 04 12:24:53 2007 -0700 (2007-02-04) |
parents | 976dd90c2fdb 01ec7dba9ff8 |
children | e0a5cef6332a |
files |
line diff
1.1 --- a/buildconfigs/linux-defconfig_xen_x86_32 Sun Feb 04 12:18:48 2007 -0700 1.2 +++ b/buildconfigs/linux-defconfig_xen_x86_32 Sun Feb 04 12:24:53 2007 -0700 1.3 @@ -1268,6 +1268,7 @@ CONFIG_IEEE1394_RAWIO=m 1.4 CONFIG_I2O=m 1.5 CONFIG_I2O_LCT_NOTIFY_ON_CHANGES=y 1.6 CONFIG_I2O_EXT_ADAPTEC=y 1.7 +CONFIG_I2O_EXT_ADAPTEC_DMA64=y 1.8 CONFIG_I2O_CONFIG=m 1.9 CONFIG_I2O_CONFIG_OLD_IOCTL=y 1.10 CONFIG_I2O_BUS=m
2.1 --- a/docs/xen-api/xenapi-datamodel.tex Sun Feb 04 12:18:48 2007 -0700 2.2 +++ b/docs/xen-api/xenapi-datamodel.tex Sun Feb 04 12:24:53 2007 -0700 2.3 @@ -142,7 +142,6 @@ The following enumeration types are used 2.4 \hspace{0.5cm}{\tt Paused} & Paused \\ 2.5 \hspace{0.5cm}{\tt Running} & Running \\ 2.6 \hspace{0.5cm}{\tt Suspended} & Suspended \\ 2.7 -\hspace{0.5cm}{\tt ShuttingDown} & Shutting Down \\ 2.8 \hspace{0.5cm}{\tt Unknown} & Some other unknown state \\ 2.9 \hline 2.10 \end{longtable} 2.11 @@ -1026,9 +1025,9 @@ references to objects with match names 2.12 virtual machine (or 'guest'). 2.13 2.14 VM booting is controlled by setting one of the two mutually exclusive 2.15 -groups: "PV", and "HVM". If HVM.boot is the empty string, then paravirtual 2.16 -domain building and booting will be used; otherwise the VM will be loaded 2.17 -as an HVM domain, and booted using an emulated BIOS. 2.18 +groups: "PV", and "HVM". If HVM.boot\_policy is the empty string, then 2.19 +paravirtual domain building and booting will be used; otherwise the VM will 2.20 +be loaded as an HVM domain, and booted using an emulated BIOS. 2.21 2.22 When paravirtual booting is in use, the PV/bootloader field indicates the 2.23 bootloader to use. It may be "pygrub", in which case the platform's 2.24 @@ -1053,7 +1052,10 @@ ramdisk values will be treated as paths 2.25 PV/bootloader and PV/kernel are empty, then the behaviour is as if 2.26 PV/bootloader was specified as "pygrub". 2.27 2.28 -When using HVM booting, HVM/boot specifies the order of the boot devices.}} \\ 2.29 +When using HVM booting, HVM/boot\_policy and HVM/boot\_params specify the 2.30 +boot handling. Only one policy is currently defined: "BIOS order". In 2.31 +this case, HVM/boot\_params should contain one key-value pair "order" = "N" 2.32 +where N is the string that will be passed to QEMU.}} \\ 2.33 \hline 2.34 Quals & Field & Type & Description \\ 2.35 \hline 2.36 @@ -1089,7 +1091,8 @@ Quals & Field & Type & Description \\ 2.37 $\mathit{RW}$ & {\tt PV/ramdisk} & string & path to the initrd \\ 2.38 $\mathit{RW}$ & {\tt PV/args} & string & kernel command-line arguments \\ 2.39 $\mathit{RW}$ & {\tt PV/bootloader\_args} & string & miscellaneous arguments for the bootloader \\ 2.40 -$\mathit{RW}$ & {\tt HVM/boot} & string & device boot order \\ 2.41 +$\mathit{RW}$ & {\tt HVM/boot\_policy} & string & HVM boot policy \\ 2.42 +$\mathit{RW}$ & {\tt HVM/boot\_params} & (string $\rightarrow$ string) Map & HVM boot params \\ 2.43 $\mathit{RW}$ & {\tt platform/std\_VGA} & bool & emulate standard VGA instead of cirrus logic \\ 2.44 $\mathit{RW}$ & {\tt platform/serial} & string & redirect serial port to pty \\ 2.45 $\mathit{RW}$ & {\tt platform/localtime} & bool & set RTC to local time \\ 2.46 @@ -3297,13 +3300,13 @@ void 2.47 \vspace{0.3cm} 2.48 \vspace{0.3cm} 2.49 \vspace{0.3cm} 2.50 -\subsubsection{RPC name:~get\_HVM\_boot} 2.51 - 2.52 -{\bf Overview:} 2.53 -Get the HVM/boot field of the given VM. 2.54 - 2.55 - \noindent {\bf Signature:} 2.56 -\begin{verbatim} string get_HVM_boot (session_id s, VM ref self)\end{verbatim} 2.57 +\subsubsection{RPC name:~get\_HVM\_boot\_policy} 2.58 + 2.59 +{\bf Overview:} 2.60 +Get the HVM/boot\_policy field of the given VM. 2.61 + 2.62 + \noindent {\bf Signature:} 2.63 +\begin{verbatim} string get_HVM_boot_policy (session_id s, VM ref self)\end{verbatim} 2.64 2.65 2.66 \noindent{\bf Arguments:} 2.67 @@ -3329,13 +3332,13 @@ value of the field 2.68 \vspace{0.3cm} 2.69 \vspace{0.3cm} 2.70 \vspace{0.3cm} 2.71 -\subsubsection{RPC name:~set\_HVM\_boot} 2.72 - 2.73 -{\bf Overview:} 2.74 -Set the HVM/boot field of the given VM. 2.75 - 2.76 - \noindent {\bf Signature:} 2.77 -\begin{verbatim} void set_HVM_boot (session_id s, VM ref self, string value)\end{verbatim} 2.78 +\subsubsection{RPC name:~set\_HVM\_boot\_policy} 2.79 + 2.80 +{\bf Overview:} 2.81 +Set the HVM/boot\_policy field of the given VM. 2.82 + 2.83 + \noindent {\bf Signature:} 2.84 +\begin{verbatim} void set_HVM_boot_policy (session_id s, VM ref self, string value)\end{verbatim} 2.85 2.86 2.87 \noindent{\bf Arguments:} 2.88 @@ -3363,6 +3366,143 @@ void 2.89 \vspace{0.3cm} 2.90 \vspace{0.3cm} 2.91 \vspace{0.3cm} 2.92 +\subsubsection{RPC name:~get\_HVM\_boot\_params} 2.93 + 2.94 +{\bf Overview:} 2.95 +Get the HVM/boot\_params field of the given VM. 2.96 + 2.97 + \noindent {\bf Signature:} 2.98 +\begin{verbatim} ((string -> string) Map) get_HVM_boot_params (session_id s, VM ref self)\end{verbatim} 2.99 + 2.100 + 2.101 +\noindent{\bf Arguments:} 2.102 + 2.103 + 2.104 +\vspace{0.3cm} 2.105 +\begin{tabular}{|c|c|p{7cm}|} 2.106 + \hline 2.107 +{\bf type} & {\bf name} & {\bf description} \\ \hline 2.108 +{\tt VM ref } & self & reference to the object \\ \hline 2.109 + 2.110 +\end{tabular} 2.111 + 2.112 +\vspace{0.3cm} 2.113 + 2.114 + \noindent {\bf Return Type:} 2.115 +{\tt 2.116 +(string $\rightarrow$ string) Map 2.117 +} 2.118 + 2.119 + 2.120 +value of the field 2.121 +\vspace{0.3cm} 2.122 +\vspace{0.3cm} 2.123 +\vspace{0.3cm} 2.124 +\subsubsection{RPC name:~set\_HVM\_boot\_params} 2.125 + 2.126 +{\bf Overview:} 2.127 +Set the HVM/boot\_params field of the given VM. 2.128 + 2.129 + \noindent {\bf Signature:} 2.130 +\begin{verbatim} void set_HVM_boot_params (session_id s, VM ref self, (string -> string) Map value)\end{verbatim} 2.131 + 2.132 + 2.133 +\noindent{\bf Arguments:} 2.134 + 2.135 + 2.136 +\vspace{0.3cm} 2.137 +\begin{tabular}{|c|c|p{7cm}|} 2.138 + \hline 2.139 +{\bf type} & {\bf name} & {\bf description} \\ \hline 2.140 +{\tt VM ref } & self & reference to the object \\ \hline 2.141 + 2.142 +{\tt (string $\rightarrow$ string) Map } & value & New value to set \\ \hline 2.143 + 2.144 +\end{tabular} 2.145 + 2.146 +\vspace{0.3cm} 2.147 + 2.148 + \noindent {\bf Return Type:} 2.149 +{\tt 2.150 +void 2.151 +} 2.152 + 2.153 + 2.154 + 2.155 +\vspace{0.3cm} 2.156 +\vspace{0.3cm} 2.157 +\vspace{0.3cm} 2.158 +\subsubsection{RPC name:~add\_to\_HVM\_boot\_params} 2.159 + 2.160 +{\bf Overview:} 2.161 +Add the given key-value pair to the HVM/boot\_params field of the given VM. 2.162 + 2.163 + \noindent {\bf Signature:} 2.164 +\begin{verbatim} void add_to_HVM_boot_params (session_id s, VM ref self, string key, string value)\end{verbatim} 2.165 + 2.166 + 2.167 +\noindent{\bf Arguments:} 2.168 + 2.169 + 2.170 +\vspace{0.3cm} 2.171 +\begin{tabular}{|c|c|p{7cm}|} 2.172 + \hline 2.173 +{\bf type} & {\bf name} & {\bf description} \\ \hline 2.174 +{\tt VM ref } & self & reference to the object \\ \hline 2.175 + 2.176 +{\tt string } & key & Key to add \\ \hline 2.177 + 2.178 +{\tt string } & value & Value to add \\ \hline 2.179 + 2.180 +\end{tabular} 2.181 + 2.182 +\vspace{0.3cm} 2.183 + 2.184 + \noindent {\bf Return Type:} 2.185 +{\tt 2.186 +void 2.187 +} 2.188 + 2.189 + 2.190 + 2.191 +\vspace{0.3cm} 2.192 +\vspace{0.3cm} 2.193 +\vspace{0.3cm} 2.194 +\subsubsection{RPC name:~remove\_from\_HVM\_boot\_params} 2.195 + 2.196 +{\bf Overview:} 2.197 +Remove the given key and its corresponding value from the HVM/boot\_params 2.198 +field of the given VM. If the key is not in that Map, then do nothing. 2.199 + 2.200 + \noindent {\bf Signature:} 2.201 +\begin{verbatim} void remove_from_HVM_boot_params (session_id s, VM ref self, string key)\end{verbatim} 2.202 + 2.203 + 2.204 +\noindent{\bf Arguments:} 2.205 + 2.206 + 2.207 +\vspace{0.3cm} 2.208 +\begin{tabular}{|c|c|p{7cm}|} 2.209 + \hline 2.210 +{\bf type} & {\bf name} & {\bf description} \\ \hline 2.211 +{\tt VM ref } & self & reference to the object \\ \hline 2.212 + 2.213 +{\tt string } & key & Key to remove \\ \hline 2.214 + 2.215 +\end{tabular} 2.216 + 2.217 +\vspace{0.3cm} 2.218 + 2.219 + \noindent {\bf Return Type:} 2.220 +{\tt 2.221 +void 2.222 +} 2.223 + 2.224 + 2.225 + 2.226 +\vspace{0.3cm} 2.227 +\vspace{0.3cm} 2.228 +\vspace{0.3cm} 2.229 \subsubsection{RPC name:~get\_platform\_std\_VGA} 2.230 2.231 {\bf Overview:} 2.232 @@ -4524,10 +4664,42 @@ void 2.233 \vspace{0.3cm} 2.234 \vspace{0.3cm} 2.235 \vspace{0.3cm} 2.236 +\subsubsection{RPC name:~dmesg} 2.237 + 2.238 +{\bf Overview:} 2.239 +Get the host xen dmesg. 2.240 + 2.241 + \noindent {\bf Signature:} 2.242 +\begin{verbatim} string dmesg (session_id s, host ref host)\end{verbatim} 2.243 + 2.244 + 2.245 +\noindent{\bf Arguments:} 2.246 + 2.247 + 2.248 +\vspace{0.3cm} 2.249 +\begin{tabular}{|c|c|p{7cm}|} 2.250 + \hline 2.251 +{\bf type} & {\bf name} & {\bf description} \\ \hline 2.252 +{\tt host ref } & host & The Host to query \\ \hline 2.253 + 2.254 +\end{tabular} 2.255 + 2.256 +\vspace{0.3cm} 2.257 + 2.258 + \noindent {\bf Return Type:} 2.259 +{\tt 2.260 +string 2.261 +} 2.262 + 2.263 + 2.264 +dmesg string 2.265 +\vspace{0.3cm} 2.266 +\vspace{0.3cm} 2.267 +\vspace{0.3cm} 2.268 \subsubsection{RPC name:~get\_all} 2.269 2.270 {\bf Overview:} 2.271 -Return a list of all the hosts known to the system 2.272 +Return a list of all the hosts known to the system. 2.273 2.274 \noindent {\bf Signature:} 2.275 \begin{verbatim} ((host ref) Set) get_all (session_id s)\end{verbatim} 2.276 @@ -11758,6 +11930,17 @@ The handle parameter echoes the bad valu 2.277 \begin{verbatim}TASK_HANDLE_INVALID(handle)\end{verbatim} 2.278 \begin{center}\rule{10em}{0.1pt}\end{center} 2.279 2.280 +\subsubsection{VALUE\_NOT\_SUPPORTED} 2.281 + 2.282 +You attempted to set a value that is not supported by this implementation. 2.283 +The fully-qualified field name and the value that you tried to set are 2.284 +returned. Also returned is a developer-only diagnostic reason. 2.285 + 2.286 +\vspace{0.3cm} 2.287 +{\bf Signature:} 2.288 +\begin{verbatim}VALUE_NOT_SUPPORTED(field, value, reason)\end{verbatim} 2.289 +\begin{center}\rule{10em}{0.1pt}\end{center} 2.290 + 2.291 \subsubsection{VBD\_HANDLE\_INVALID} 2.292 2.293 You gave an invalid VBD handle. The VBD may have recently been deleted.
3.1 --- a/extras/mini-os/arch/x86/x86_32.S Sun Feb 04 12:18:48 2007 -0700 3.2 +++ b/extras/mini-os/arch/x86/x86_32.S Sun Feb 04 12:24:53 2007 -0700 3.3 @@ -69,7 +69,7 @@ CS = 0x2C 3.4 popl %ds; \ 3.5 popl %es; \ 3.6 addl $4,%esp; \ 3.7 - iret; \ 3.8 + iret; 3.9 3.10 ENTRY(divide_error) 3.11 pushl $0 # no error code 3.12 @@ -101,10 +101,9 @@ do_exception: 3.13 jmp ret_from_exception 3.14 3.15 ret_from_exception: 3.16 - movb CS(%esp),%cl 3.17 - test $2,%cl # slow return to ring 2 or 3 3.18 - jne safesti 3.19 - RESTORE_ALL 3.20 + movb CS(%esp),%cl 3.21 + addl $8,%esp 3.22 + RESTORE_ALL 3.23 3.24 # A note on the "critical region" in our callback handler. 3.25 # We want to avoid stacking callback handlers due to events occurring
4.1 --- a/extras/mini-os/xenbus/xenbus.c Sun Feb 04 12:18:48 2007 -0700 4.2 +++ b/extras/mini-os/xenbus/xenbus.c Sun Feb 04 12:24:53 2007 -0700 4.3 @@ -178,6 +178,7 @@ static void release_xenbus_id(int id) 4.4 BUG_ON(!req_info[id].in_use); 4.5 spin_lock(&req_lock); 4.6 nr_live_reqs--; 4.7 + req_info[id].in_use = 0; 4.8 if (nr_live_reqs == NR_REQS - 1) 4.9 wake_up(&req_wq); 4.10 spin_unlock(&req_lock); 4.11 @@ -212,6 +213,7 @@ static int allocate_xenbus_id(void) 4.12 probe = o_probe + 1; 4.13 spin_unlock(&req_lock); 4.14 init_waitqueue_head(&req_info[o_probe].waitq); 4.15 + 4.16 return o_probe; 4.17 } 4.18
5.1 --- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c Sun Feb 04 12:18:48 2007 -0700 5.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c Sun Feb 04 12:24:53 2007 -0700 5.3 @@ -1935,8 +1935,6 @@ static struct net_device * __devinit cre 5.4 np = netdev_priv(netdev); 5.5 np->xbdev = dev; 5.6 5.7 - netif_carrier_off(netdev); 5.8 - 5.9 spin_lock_init(&np->tx_lock); 5.10 spin_lock_init(&np->rx_lock); 5.11 5.12 @@ -1991,6 +1989,9 @@ static struct net_device * __devinit cre 5.13 SET_NETDEV_DEV(netdev, &dev->dev); 5.14 5.15 np->netdev = netdev; 5.16 + 5.17 + netif_carrier_off(netdev); 5.18 + 5.19 return netdev; 5.20 5.21 exit_free_tx:
6.1 --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_client.c Sun Feb 04 12:18:48 2007 -0700 6.2 +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_client.c Sun Feb 04 12:24:53 2007 -0700 6.3 @@ -42,9 +42,9 @@ 6.4 #define DPRINTK(fmt, args...) \ 6.5 pr_debug("xenbus_client (%s:%d) " fmt ".\n", __FUNCTION__, __LINE__, ##args) 6.6 6.7 -char *xenbus_strstate(enum xenbus_state state) 6.8 +const char *xenbus_strstate(enum xenbus_state state) 6.9 { 6.10 - static char *name[] = { 6.11 + static const char *const name[] = { 6.12 [ XenbusStateUnknown ] = "Unknown", 6.13 [ XenbusStateInitialising ] = "Initialising", 6.14 [ XenbusStateInitWait ] = "InitWait", 6.15 @@ -55,6 +55,7 @@ char *xenbus_strstate(enum xenbus_state 6.16 }; 6.17 return (state < ARRAY_SIZE(name)) ? name[state] : "INVALID"; 6.18 } 6.19 +EXPORT_SYMBOL_GPL(xenbus_strstate); 6.20 6.21 int xenbus_watch_path(struct xenbus_device *dev, const char *path, 6.22 struct xenbus_watch *watch,
7.1 --- a/linux-2.6-xen-sparse/include/xen/xenbus.h Sun Feb 04 12:18:48 2007 -0700 7.2 +++ b/linux-2.6-xen-sparse/include/xen/xenbus.h Sun Feb 04 12:24:53 2007 -0700 7.3 @@ -295,7 +295,7 @@ void xenbus_dev_fatal(struct xenbus_devi 7.4 7.5 int __init xenbus_dev_init(void); 7.6 7.7 -char *xenbus_strstate(enum xenbus_state state); 7.8 +const char *xenbus_strstate(enum xenbus_state state); 7.9 int xenbus_dev_is_online(struct xenbus_device *dev); 7.10 int xenbus_frontend_closed(struct xenbus_device *dev); 7.11
8.1 --- a/patches/linux-2.6.18/xenoprof-generic.patch Sun Feb 04 12:18:48 2007 -0700 8.2 +++ b/patches/linux-2.6.18/xenoprof-generic.patch Sun Feb 04 12:24:53 2007 -0700 8.3 @@ -363,9 +363,9 @@ diff -pruN ../orig-linux-2.6.18/drivers/ 8.4 + if (!oprofile_ops.set_active) 8.5 + return -EINVAL; 8.6 + 8.7 -+ down(&start_sem); 8.8 ++ mutex_lock(&start_mutex); 8.9 + err = oprofile_ops.set_active(active_domains, adomains); 8.10 -+ up(&start_sem); 8.11 ++ mutex_unlock(&start_mutex); 8.12 + return err; 8.13 +} 8.14 + 8.15 @@ -376,9 +376,9 @@ diff -pruN ../orig-linux-2.6.18/drivers/ 8.16 + if (!oprofile_ops.set_passive) 8.17 + return -EINVAL; 8.18 + 8.19 -+ down(&start_sem); 8.20 ++ mutex_lock(&start_mutex); 8.21 + err = oprofile_ops.set_passive(passive_domains, pdomains); 8.22 -+ up(&start_sem); 8.23 ++ mutex_unlock(&start_mutex); 8.24 + return err; 8.25 +} 8.26 +
9.1 --- a/tools/Rules.mk Sun Feb 04 12:18:48 2007 -0700 9.2 +++ b/tools/Rules.mk Sun Feb 04 12:24:53 2007 -0700 9.3 @@ -56,6 +56,6 @@ mk-symlinks-xen: 9.4 ( cd xen/foreign && ln -sf ../../$(XEN_ROOT)/xen/include/public/foreign/Makefile . ) 9.5 ( cd xen/foreign && ln -sf ../../$(XEN_ROOT)/xen/include/public/foreign/reference.size . ) 9.6 ( cd xen/foreign && ln -sf ../../$(XEN_ROOT)/xen/include/public/foreign/*.py . ) 9.7 - make -C xen/foreign 9.8 + $(MAKE) -C xen/foreign 9.9 9.10 mk-symlinks: mk-symlinks-xen mk-symlinks-$(XEN_OS)
10.1 --- a/tools/libxc/xc_dom_boot.c Sun Feb 04 12:18:48 2007 -0700 10.2 +++ b/tools/libxc/xc_dom_boot.c Sun Feb 04 12:24:53 2007 -0700 10.3 @@ -144,7 +144,7 @@ static int x86_shadow(int xc, domid_t do 10.4 return rc; 10.5 } 10.6 10.7 -static int arch_setup_early(struct xc_dom_image *dom) 10.8 +static int arch_setup_meminit(struct xc_dom_image *dom) 10.9 { 10.10 int rc = 0; 10.11 10.12 @@ -157,13 +157,13 @@ static int arch_setup_early(struct xc_do 10.13 return rc; 10.14 } 10.15 10.16 -static int arch_setup_middle(struct xc_dom_image *dom) 10.17 +static int arch_setup_bootearly(struct xc_dom_image *dom) 10.18 { 10.19 xc_dom_printf("%s: doing nothing\n", __FUNCTION__); 10.20 return 0; 10.21 } 10.22 10.23 -static int arch_setup_late(struct xc_dom_image *dom) 10.24 +static int arch_setup_bootlate(struct xc_dom_image *dom) 10.25 { 10.26 static const struct { 10.27 char *guest; 10.28 @@ -263,13 +263,13 @@ static int arch_setup_late(struct xc_dom 10.29 10.30 #elif defined(__ia64__) 10.31 10.32 -static int arch_setup_early(struct xc_dom_image *dom) 10.33 +static int arch_setup_meminit(struct xc_dom_image *dom) 10.34 { 10.35 xc_dom_printf("%s: doing nothing\n", __FUNCTION__); 10.36 return 0; 10.37 } 10.38 10.39 -static int arch_setup_middle(struct xc_dom_image *dom) 10.40 +static int arch_setup_bootearly(struct xc_dom_image *dom) 10.41 { 10.42 DECLARE_DOMCTL; 10.43 int rc; 10.44 @@ -281,10 +281,6 @@ static int arch_setup_middle(struct xc_d 10.45 domctl.domain = dom->guest_domid; 10.46 domctl.u.arch_setup.flags = 0; 10.47 10.48 - /* dom->start_info_pfn should be initialized by alloc_magic_pages(). 10.49 - * However it is called later. So we initialize here. 10.50 - */ 10.51 - dom->start_info_pfn = dom->total_pages - 3; 10.52 domctl.u.arch_setup.bp = (dom->start_info_pfn << PAGE_SHIFT) 10.53 + sizeof(start_info_t); 10.54 /* 3 = start info page, xenstore page and console page */ 10.55 @@ -293,7 +289,7 @@ static int arch_setup_middle(struct xc_d 10.56 return rc; 10.57 } 10.58 10.59 -static int arch_setup_late(struct xc_dom_image *dom) 10.60 +static int arch_setup_bootlate(struct xc_dom_image *dom) 10.61 { 10.62 unsigned int page_size = XC_DOM_PAGE_SIZE(dom); 10.63 shared_info_t *shared_info; 10.64 @@ -317,19 +313,19 @@ static int arch_setup_late(struct xc_dom 10.65 10.66 #elif defined(__powerpc64__) 10.67 10.68 -static int arch_setup_early(struct xc_dom_image *dom) 10.69 +static int arch_setup_meminit(struct xc_dom_image *dom) 10.70 { 10.71 xc_dom_printf("%s: doing nothing\n", __FUNCTION__); 10.72 return 0; 10.73 } 10.74 10.75 -static int arch_setup_middle(struct xc_dom_image *dom) 10.76 +static int arch_setup_bootearly(struct xc_dom_image *dom) 10.77 { 10.78 xc_dom_printf("%s: doing nothing\n", __FUNCTION__); 10.79 return 0; 10.80 } 10.81 10.82 -static int arch_setup_late(struct xc_dom_image *dom) 10.83 +static int arch_setup_bootlate(struct xc_dom_image *dom) 10.84 { 10.85 start_info_t *si = 10.86 xc_dom_pfn_to_ptr(dom, dom->start_info_pfn, 1); 10.87 @@ -355,19 +351,19 @@ static int arch_setup_late(struct xc_dom 10.88 10.89 #else 10.90 10.91 -static int arch_setup_early(struct xc_dom_image *dom) 10.92 +static int arch_setup_meminit(struct xc_dom_image *dom) 10.93 { 10.94 xc_dom_printf("%s: doing nothing\n", __FUNCTION__); 10.95 return 0; 10.96 } 10.97 10.98 -static int arch_setup_middle(struct xc_dom_image *dom) 10.99 +static int arch_setup_bootearly(struct xc_dom_image *dom) 10.100 { 10.101 xc_dom_printf("%s: doing nothing\n", __FUNCTION__); 10.102 return 0; 10.103 } 10.104 10.105 -static int arch_setup_late(struct xc_dom_image *dom) 10.106 +static int arch_setup_bootlate(struct xc_dom_image *dom) 10.107 { 10.108 xc_dom_printf("%s: doing nothing\n", __FUNCTION__); 10.109 return 0; 10.110 @@ -423,7 +419,7 @@ int xc_dom_boot_mem_init(struct xc_dom_i 10.111 10.112 xc_dom_printf("%s: called\n", __FUNCTION__); 10.113 10.114 - if (0 != (rc = arch_setup_early(dom))) 10.115 + if (0 != (rc = arch_setup_meminit(dom))) 10.116 return rc; 10.117 10.118 /* allocate guest memory */ 10.119 @@ -438,9 +434,6 @@ int xc_dom_boot_mem_init(struct xc_dom_i 10.120 return rc; 10.121 } 10.122 10.123 - if (0 != (rc = arch_setup_middle(dom))) 10.124 - return rc; 10.125 - 10.126 return 0; 10.127 } 10.128 10.129 @@ -497,6 +490,10 @@ int xc_dom_boot_image(struct xc_dom_imag 10.130 10.131 xc_dom_printf("%s: called\n", __FUNCTION__); 10.132 10.133 + /* misc ia64 stuff*/ 10.134 + if (0 != (rc = arch_setup_bootearly(dom))) 10.135 + return rc; 10.136 + 10.137 /* collect some info */ 10.138 domctl.cmd = XEN_DOMCTL_getdomaininfo; 10.139 domctl.domain = dom->guest_domid; 10.140 @@ -542,7 +539,7 @@ int xc_dom_boot_image(struct xc_dom_imag 10.141 xc_dom_log_memory_footprint(dom); 10.142 10.143 /* misc x86 stuff */ 10.144 - if (0 != (rc = arch_setup_late(dom))) 10.145 + if (0 != (rc = arch_setup_bootlate(dom))) 10.146 return rc; 10.147 10.148 /* let the vm run */
11.1 --- a/tools/libxc/xc_dom_core.c Sun Feb 04 12:18:48 2007 -0700 11.2 +++ b/tools/libxc/xc_dom_core.c Sun Feb 04 12:24:53 2007 -0700 11.3 @@ -717,6 +717,9 @@ int xc_dom_build_image(struct xc_dom_ima 11.4 } 11.5 page_size = XC_DOM_PAGE_SIZE(dom); 11.6 11.7 + /* 4MB align virtual base address */ 11.8 + dom->parms.virt_base &= ~(((uint64_t)1<<22)-1); 11.9 + 11.10 /* load kernel */ 11.11 if (0 != xc_dom_alloc_segment(dom, &dom->kernel_seg, "kernel", 11.12 dom->kernel_seg.vstart,
12.1 --- a/tools/libxc/xc_dom_ia64.c Sun Feb 04 12:18:48 2007 -0700 12.2 +++ b/tools/libxc/xc_dom_ia64.c Sun Feb 04 12:24:53 2007 -0700 12.3 @@ -26,11 +26,7 @@ static int alloc_magic_pages(struct xc_d 12.4 /* allocate special pages */ 12.5 dom->console_pfn = dom->total_pages -1; 12.6 dom->xenstore_pfn = dom->total_pages -2; 12.7 - 12.8 - /* 12.9 - * this is initialized by arch_setup_middle(). 12.10 - * dom->start_info_pfn = dom->total_pages -3; 12.11 - */ 12.12 + dom->start_info_pfn = dom->total_pages -3; 12.13 return 0; 12.14 } 12.15
13.1 --- a/tools/libxc/xc_dom_x86.c Sun Feb 04 12:18:48 2007 -0700 13.2 +++ b/tools/libxc/xc_dom_x86.c Sun Feb 04 12:24:53 2007 -0700 13.3 @@ -66,11 +66,12 @@ static int count_pgtables(struct xc_dom_ 13.4 13.5 extra_pages = dom->alloc_bootstack ? 1 : 0; 13.6 extra_pages += dom->extra_pages; 13.7 + extra_pages += 128; /* 512kB padding */ 13.8 pages = extra_pages; 13.9 for (;;) 13.10 { 13.11 try_virt_end = round_up(dom->virt_alloc_end + pages * PAGE_SIZE_X86, 13.12 - bits_to_mask(l1_bits)); 13.13 + bits_to_mask(22)); /* 4MB alignment */ 13.14 dom->pg_l4 = 13.15 nr_page_tables(dom->parms.virt_base, try_virt_end, l4_bits); 13.16 dom->pg_l3 = 13.17 @@ -313,6 +314,7 @@ static int alloc_magic_pages(struct xc_d 13.18 if (xc_dom_feature_translated(dom)) 13.19 dom->shared_info_pfn = xc_dom_alloc_page(dom, "shared info"); 13.20 dom->alloc_bootstack = 1; 13.21 + 13.22 return 0; 13.23 } 13.24
14.1 --- a/tools/libxc/xc_domain.c Sun Feb 04 12:18:48 2007 -0700 14.2 +++ b/tools/libxc/xc_domain.c Sun Feb 04 12:24:53 2007 -0700 14.3 @@ -241,45 +241,49 @@ int xc_domain_getinfolist(int xc_handle, 14.4 /* get info from hvm guest for save */ 14.5 int xc_domain_hvm_getcontext(int xc_handle, 14.6 uint32_t domid, 14.7 - hvm_domain_context_t *hvm_ctxt) 14.8 + uint8_t *ctxt_buf, 14.9 + uint32_t size) 14.10 { 14.11 - int rc; 14.12 + int ret; 14.13 DECLARE_DOMCTL; 14.14 14.15 domctl.cmd = XEN_DOMCTL_gethvmcontext; 14.16 domctl.domain = (domid_t)domid; 14.17 - set_xen_guest_handle(domctl.u.hvmcontext.ctxt, hvm_ctxt); 14.18 + domctl.u.hvmcontext.size = size; 14.19 + set_xen_guest_handle(domctl.u.hvmcontext.buffer, ctxt_buf); 14.20 14.21 - if ( (rc = mlock(hvm_ctxt, sizeof(*hvm_ctxt))) != 0 ) 14.22 - return rc; 14.23 + if ( (ret = lock_pages(ctxt_buf, size)) != 0 ) 14.24 + return ret; 14.25 14.26 - rc = do_domctl(xc_handle, &domctl); 14.27 + ret = do_domctl(xc_handle, &domctl); 14.28 14.29 - safe_munlock(hvm_ctxt, sizeof(*hvm_ctxt)); 14.30 + unlock_pages(ctxt_buf, size); 14.31 14.32 - return rc; 14.33 + return (ret < 0 ? -1 : domctl.u.hvmcontext.size); 14.34 } 14.35 14.36 /* set info to hvm guest for restore */ 14.37 int xc_domain_hvm_setcontext(int xc_handle, 14.38 uint32_t domid, 14.39 - hvm_domain_context_t *hvm_ctxt) 14.40 + uint8_t *ctxt_buf, 14.41 + uint32_t size) 14.42 { 14.43 - int rc; 14.44 + int ret; 14.45 DECLARE_DOMCTL; 14.46 14.47 domctl.cmd = XEN_DOMCTL_sethvmcontext; 14.48 domctl.domain = domid; 14.49 - set_xen_guest_handle(domctl.u.hvmcontext.ctxt, hvm_ctxt); 14.50 + domctl.u.hvmcontext.size = size; 14.51 + set_xen_guest_handle(domctl.u.hvmcontext.buffer, ctxt_buf); 14.52 14.53 - if ( (rc = mlock(hvm_ctxt, sizeof(*hvm_ctxt))) != 0 ) 14.54 - return rc; 14.55 + if ( (ret = lock_pages(ctxt_buf, size)) != 0 ) 14.56 + return ret; 14.57 14.58 - rc = do_domctl(xc_handle, &domctl); 14.59 + ret = do_domctl(xc_handle, &domctl); 14.60 14.61 - safe_munlock(hvm_ctxt, sizeof(*hvm_ctxt)); 14.62 + unlock_pages(ctxt_buf, size); 14.63 14.64 - return rc; 14.65 + return ret; 14.66 } 14.67 14.68 int xc_vcpu_getcontext(int xc_handle,
15.1 --- a/tools/libxc/xc_hvm_restore.c Sun Feb 04 12:18:48 2007 -0700 15.2 +++ b/tools/libxc/xc_hvm_restore.c Sun Feb 04 12:24:53 2007 -0700 15.3 @@ -87,7 +87,7 @@ int xc_hvm_restore(int xc_handle, int io 15.4 xc_dominfo_t info; 15.5 unsigned int rc = 1, n, i; 15.6 uint32_t rec_len, nr_vcpus; 15.7 - hvm_domain_context_t hvm_ctxt; 15.8 + uint8_t *hvm_buf = NULL; 15.9 unsigned long long v_end, memsize; 15.10 unsigned long shared_page_nr; 15.11 15.12 @@ -128,8 +128,7 @@ int xc_hvm_restore(int xc_handle, int io 15.13 } 15.14 15.15 15.16 - p2m = malloc(max_pfn * sizeof(xen_pfn_t)); 15.17 - 15.18 + p2m = malloc(max_pfn * sizeof(xen_pfn_t)); 15.19 if (p2m == NULL) { 15.20 ERROR("memory alloc failed"); 15.21 errno = ENOMEM; 15.22 @@ -297,18 +296,21 @@ int xc_hvm_restore(int xc_handle, int io 15.23 ERROR("error read hvm context size!\n"); 15.24 goto out; 15.25 } 15.26 - if (rec_len != sizeof(hvm_ctxt)) { 15.27 - ERROR("hvm context size dismatch!\n"); 15.28 + 15.29 + hvm_buf = malloc(rec_len); 15.30 + if (hvm_buf == NULL) { 15.31 + ERROR("memory alloc for hvm context buffer failed"); 15.32 + errno = ENOMEM; 15.33 goto out; 15.34 } 15.35 15.36 - if (!read_exact(io_fd, &hvm_ctxt, sizeof(hvm_ctxt))) { 15.37 - ERROR("error read hvm context!\n"); 15.38 + if (!read_exact(io_fd, hvm_buf, rec_len)) { 15.39 + ERROR("error read hvm buffer!\n"); 15.40 goto out; 15.41 } 15.42 15.43 - if (( rc = xc_domain_hvm_setcontext(xc_handle, dom, &hvm_ctxt))) { 15.44 - ERROR("error set hvm context!\n"); 15.45 + if (( rc = xc_domain_hvm_setcontext(xc_handle, dom, hvm_buf, rec_len))) { 15.46 + ERROR("error set hvm buffer!\n"); 15.47 goto out; 15.48 } 15.49 15.50 @@ -361,6 +363,7 @@ int xc_hvm_restore(int xc_handle, int io 15.51 if ( (rc != 0) && (dom != 0) ) 15.52 xc_domain_destroy(xc_handle, dom); 15.53 free(p2m); 15.54 + free(hvm_buf); 15.55 15.56 DPRINTF("Restore exit with rc=%d\n", rc); 15.57
16.1 --- a/tools/libxc/xc_hvm_save.c Sun Feb 04 12:18:48 2007 -0700 16.2 +++ b/tools/libxc/xc_hvm_save.c Sun Feb 04 12:24:53 2007 -0700 16.3 @@ -33,6 +33,12 @@ 16.4 #include "xg_save_restore.h" 16.5 16.6 /* 16.7 + * Size of a buffer big enough to take the HVM state of a domain. 16.8 + * Ought to calculate this a bit more carefully, or maybe ask Xen. 16.9 + */ 16.10 +#define HVM_CTXT_SIZE 8192 16.11 + 16.12 +/* 16.13 ** Default values for important tuning parameters. Can override by passing 16.14 ** non-zero replacement values to xc_hvm_save(). 16.15 ** 16.16 @@ -279,8 +285,8 @@ int xc_hvm_save(int xc_handle, int io_fd 16.17 unsigned long *pfn_type = NULL; 16.18 unsigned long *pfn_batch = NULL; 16.19 16.20 - /* A copy of hvm domain context */ 16.21 - hvm_domain_context_t hvm_ctxt; 16.22 + /* A copy of hvm domain context buffer*/ 16.23 + uint8_t *hvm_buf = NULL; 16.24 16.25 /* Live mapping of shared info structure */ 16.26 shared_info_t *live_shinfo = NULL; 16.27 @@ -423,8 +429,12 @@ int xc_hvm_save(int xc_handle, int io_fd 16.28 to_send = malloc(BITMAP_SIZE); 16.29 to_skip = malloc(BITMAP_SIZE); 16.30 16.31 - if (!to_send ||!to_skip) { 16.32 - ERROR("Couldn't allocate to_send array"); 16.33 + page_array = (unsigned long *) malloc( sizeof(unsigned long) * max_pfn); 16.34 + 16.35 + hvm_buf = malloc(HVM_CTXT_SIZE); 16.36 + 16.37 + if (!to_send ||!to_skip ||!page_array ||!hvm_buf ) { 16.38 + ERROR("Couldn't allocate memory"); 16.39 goto out; 16.40 } 16.41 16.42 @@ -444,11 +454,6 @@ int xc_hvm_save(int xc_handle, int io_fd 16.43 analysis_phase(xc_handle, dom, max_pfn, to_skip, 0); 16.44 16.45 /* get all the HVM domain pfns */ 16.46 - if ( (page_array = (unsigned long *) malloc (sizeof(unsigned long) * max_pfn)) == NULL) { 16.47 - ERROR("HVM:malloc fail!\n"); 16.48 - goto out; 16.49 - } 16.50 - 16.51 for ( i = 0; i < max_pfn; i++) 16.52 page_array[i] = i; 16.53 16.54 @@ -655,24 +660,18 @@ int xc_hvm_save(int xc_handle, int io_fd 16.55 goto out; 16.56 } 16.57 16.58 - /* save hvm hypervisor state including pic/pit/shpage */ 16.59 - if (mlock(&hvm_ctxt, sizeof(hvm_ctxt))) { 16.60 - ERROR("Unable to mlock ctxt"); 16.61 - return 1; 16.62 - } 16.63 - 16.64 - if (xc_domain_hvm_getcontext(xc_handle, dom, &hvm_ctxt)){ 16.65 - ERROR("HVM:Could not get hvm context"); 16.66 + if ( (rec_size = xc_domain_hvm_getcontext(xc_handle, dom, hvm_buf, 16.67 + HVM_CTXT_SIZE)) == -1) { 16.68 + ERROR("HVM:Could not get hvm buffer"); 16.69 goto out; 16.70 } 16.71 16.72 - rec_size = sizeof(hvm_ctxt); 16.73 if (!write_exact(io_fd, &rec_size, sizeof(uint32_t))) { 16.74 - ERROR("error write hvm ctxt size"); 16.75 + ERROR("error write hvm buffer size"); 16.76 goto out; 16.77 } 16.78 16.79 - if ( !write_exact(io_fd, &hvm_ctxt, sizeof(hvm_ctxt)) ) { 16.80 + if ( !write_exact(io_fd, hvm_buf, rec_size) ) { 16.81 ERROR("write HVM info failed!\n"); 16.82 } 16.83 16.84 @@ -722,6 +721,7 @@ int xc_hvm_save(int xc_handle, int io_fd 16.85 } 16.86 } 16.87 16.88 + free(hvm_buf); 16.89 free(page_array); 16.90 16.91 free(pfn_type);
17.1 --- a/tools/libxc/xc_linux_save.c Sun Feb 04 12:18:48 2007 -0700 17.2 +++ b/tools/libxc/xc_linux_save.c Sun Feb 04 12:24:53 2007 -0700 17.3 @@ -536,8 +536,6 @@ static int canonicalize_pagetable(unsign 17.4 if (!MFN_IS_IN_PSEUDOPHYS_MAP(mfn)) { 17.5 /* This will happen if the type info is stale which 17.6 is quite feasible under live migration */ 17.7 - DPRINTF("PT Race: [%08lx,%d] pte=%llx, mfn=%08lx\n", 17.8 - type, i, (unsigned long long)pte, mfn); 17.9 pfn = 0; /* zap it - we'll retransmit this page later */ 17.10 race = 1; /* inform the caller of race; fatal if !live */ 17.11 } else
18.1 --- a/tools/libxc/xenctrl.h Sun Feb 04 12:18:48 2007 -0700 18.2 +++ b/tools/libxc/xenctrl.h Sun Feb 04 12:24:53 2007 -0700 18.3 @@ -328,13 +328,15 @@ int xc_domain_getinfolist(int xc_handle, 18.4 * This function returns information about the context of a hvm domain 18.5 * @parm xc_handle a handle to an open hypervisor interface 18.6 * @parm domid the domain to get information from 18.7 - * @parm hvm_ctxt a pointer to a structure to store the execution context of the 18.8 - * hvm domain 18.9 + * @parm ctxt_buf a pointer to a structure to store the execution context of 18.10 + * the hvm domain 18.11 + * @parm size the size of ctxt_buf in bytes 18.12 * @return 0 on success, -1 on failure 18.13 */ 18.14 int xc_domain_hvm_getcontext(int xc_handle, 18.15 uint32_t domid, 18.16 - hvm_domain_context_t *hvm_ctxt); 18.17 + uint8_t *ctxt_buf, 18.18 + uint32_t size); 18.19 18.20 /** 18.21 * This function will set the context for hvm domain 18.22 @@ -342,11 +344,13 @@ int xc_domain_hvm_getcontext(int xc_hand 18.23 * @parm xc_handle a handle to an open hypervisor interface 18.24 * @parm domid the domain to set the hvm domain context for 18.25 * @parm hvm_ctxt pointer to the the hvm context with the values to set 18.26 + * @parm size the size of hvm_ctxt in bytes 18.27 * @return 0 on success, -1 on failure 18.28 */ 18.29 int xc_domain_hvm_setcontext(int xc_handle, 18.30 uint32_t domid, 18.31 - hvm_domain_context_t *hvm_ctxt); 18.32 + uint8_t *hvm_ctxt, 18.33 + uint32_t size); 18.34 18.35 /** 18.36 * This function returns information about the execution context of a
19.1 --- a/tools/libxen/Makefile Sun Feb 04 12:18:48 2007 -0700 19.2 +++ b/tools/libxen/Makefile Sun Feb 04 12:24:53 2007 -0700 19.3 @@ -51,6 +51,9 @@ libxenapi.a: $(LIBXENAPI_OBJS) 19.4 test/test_bindings: test/test_bindings.o libxenapi.so 19.5 $(CC) $(LDFLAGS) -o $@ $< -L . -lxenapi 19.6 19.7 +test/test_hvm_bindings: test/test_hvm_bindings.o libxenapi.so 19.8 + $(CC) $(LDFLAGS) -o $@ $< -L . -lxenapi 19.9 + 19.10 19.11 .PHONY: install 19.12 install: all
20.1 --- a/tools/libxen/include/xen_host.h Sun Feb 04 12:18:48 2007 -0700 20.2 +++ b/tools/libxen/include/xen_host.h Sun Feb 04 12:24:53 2007 -0700 20.3 @@ -394,6 +394,13 @@ xen_host_reboot(xen_session *session, xe 20.4 20.5 20.6 /** 20.7 + * Get the host xen dmesg. 20.8 + */ 20.9 +extern bool 20.10 +xen_host_dmesg(xen_session *session, char **result, xen_host host); 20.11 + 20.12 + 20.13 +/** 20.14 * Return a list of all the hosts known to the system. 20.15 */ 20.16 extern bool
21.1 --- a/tools/libxen/include/xen_vdi.h Sun Feb 04 12:18:48 2007 -0700 21.2 +++ b/tools/libxen/include/xen_vdi.h Sun Feb 04 12:24:53 2007 -0700 21.3 @@ -74,6 +74,7 @@ typedef struct xen_vdi_record 21.4 int64_t virtual_size; 21.5 int64_t physical_utilisation; 21.6 int64_t sector_size; 21.7 + char *location; 21.8 enum xen_vdi_type type; 21.9 bool sharable; 21.10 bool read_only;
22.1 --- a/tools/libxen/include/xen_vm.h Sun Feb 04 12:18:48 2007 -0700 22.2 +++ b/tools/libxen/include/xen_vm.h Sun Feb 04 12:24:53 2007 -0700 22.3 @@ -42,9 +42,9 @@ 22.4 * A virtual machine (or 'guest'). 22.5 * 22.6 * VM booting is controlled by setting one of the two mutually exclusive 22.7 - * groups: "PV", and "HVM". If HVM.boot is the empty string, then paravirtual 22.8 - * domain building and booting will be used; otherwise the VM will be loaded 22.9 - * as an HVM domain, and booted using an emulated BIOS. 22.10 + * groups: "PV", and "HVM". If HVM.boot_policy is the empty string, then 22.11 + * paravirtual domain building and booting will be used; otherwise the VM will 22.12 + * be loaded as an HVM domain, and booted using an emulated BIOS. 22.13 * 22.14 * When paravirtual booting is in use, the PV/bootloader field indicates the 22.15 * bootloader to use. It may be "pygrub", in which case the platform's 22.16 @@ -69,7 +69,10 @@ 22.17 * PV/bootloader and PV/kernel are empty, then the behaviour is as if 22.18 * PV/bootloader was specified as "pygrub". 22.19 * 22.20 - * When using HVM booting, HVM/boot specifies the order of the boot devices. 22.21 + * When using HVM booting, HVM/boot_policy and HVM/boot_params specify the 22.22 + * boot handling. Only one policy is currently defined: "BIOS order". In 22.23 + * this case, HVM/boot_params should contain one key-value pair "order" = "N" 22.24 + * where N is the string that will be passed to QEMU.. 22.25 */ 22.26 22.27 22.28 @@ -136,7 +139,8 @@ typedef struct xen_vm_record 22.29 char *pv_ramdisk; 22.30 char *pv_args; 22.31 char *pv_bootloader_args; 22.32 - char *hvm_boot; 22.33 + char *hvm_boot_policy; 22.34 + xen_string_string_map *hvm_boot_params; 22.35 bool platform_std_vga; 22.36 char *platform_serial; 22.37 bool platform_localtime; 22.38 @@ -490,10 +494,17 @@ xen_vm_get_pv_bootloader_args(xen_sessio 22.39 22.40 22.41 /** 22.42 - * Get the HVM/boot field of the given VM. 22.43 + * Get the HVM/boot_policy field of the given VM. 22.44 */ 22.45 extern bool 22.46 -xen_vm_get_hvm_boot(xen_session *session, char **result, xen_vm vm); 22.47 +xen_vm_get_hvm_boot_policy(xen_session *session, char **result, xen_vm vm); 22.48 + 22.49 + 22.50 +/** 22.51 + * Get the HVM/boot_params field of the given VM. 22.52 + */ 22.53 +extern bool 22.54 +xen_vm_get_hvm_boot_params(xen_session *session, xen_string_string_map **result, xen_vm vm); 22.55 22.56 22.57 /** 22.58 @@ -731,10 +742,34 @@ xen_vm_set_pv_bootloader_args(xen_sessio 22.59 22.60 22.61 /** 22.62 - * Set the HVM/boot field of the given VM. 22.63 + * Set the HVM/boot_policy field of the given VM. 22.64 + */ 22.65 +extern bool 22.66 +xen_vm_set_hvm_boot_policy(xen_session *session, xen_vm vm, char *boot_policy); 22.67 + 22.68 + 22.69 +/** 22.70 + * Set the HVM/boot_params field of the given VM. 22.71 */ 22.72 extern bool 22.73 -xen_vm_set_hvm_boot(xen_session *session, xen_vm vm, char *boot); 22.74 +xen_vm_set_hvm_boot_params(xen_session *session, xen_vm vm, xen_string_string_map *boot_params); 22.75 + 22.76 + 22.77 +/** 22.78 + * Add the given key-value pair to the HVM/boot_params field of the 22.79 + * given VM. 22.80 + */ 22.81 +extern bool 22.82 +xen_vm_add_to_hvm_boot_params(xen_session *session, xen_vm vm, char *key, char *value); 22.83 + 22.84 + 22.85 +/** 22.86 + * Remove the given key and its corresponding value from the 22.87 + * HVM/boot_params field of the given VM. If the key is not in that Map, then 22.88 + * do nothing. 22.89 + */ 22.90 +extern bool 22.91 +xen_vm_remove_from_hvm_boot_params(xen_session *session, xen_vm vm, char *key); 22.92 22.93 22.94 /**
23.1 --- a/tools/libxen/include/xen_vm_power_state.h Sun Feb 04 12:18:48 2007 -0700 23.2 +++ b/tools/libxen/include/xen_vm_power_state.h Sun Feb 04 12:24:53 2007 -0700 23.3 @@ -46,11 +46,6 @@ enum xen_vm_power_state 23.4 XEN_VM_POWER_STATE_SUSPENDED, 23.5 23.6 /** 23.7 - * Shutting Down 23.8 - */ 23.9 - XEN_VM_POWER_STATE_SHUTTINGDOWN, 23.10 - 23.11 - /** 23.12 * Some other unknown state 23.13 */ 23.14 XEN_VM_POWER_STATE_UNKNOWN
24.1 --- a/tools/libxen/src/xen_common.c Sun Feb 04 12:18:48 2007 -0700 24.2 +++ b/tools/libxen/src/xen_common.c Sun Feb 04 12:24:53 2007 -0700 24.3 @@ -1,5 +1,5 @@ 24.4 /* 24.5 - * Copyright (c) 2006 XenSource, Inc. 24.6 + * Copyright (c) 2006-2007 XenSource, Inc. 24.7 * 24.8 * This library is free software; you can redistribute it and/or 24.9 * modify it under the terms of the GNU Lesser General Public 24.10 @@ -86,6 +86,8 @@ static xmlNode * 24.11 add_param_struct(xmlNode *); 24.12 static xmlNode * 24.13 add_struct_array(xmlNode *, const char *); 24.14 +static xmlNode * 24.15 +add_nested_struct(xmlNode *, const char *); 24.16 static void 24.17 add_struct_member(xmlNode *, const char *, const char *, const char *); 24.18 static void 24.19 @@ -107,6 +109,9 @@ parse_structmap_value(xen_session *, xml 24.20 24.21 static size_t size_of_member(const abstract_type *); 24.22 24.23 +static const char * 24.24 +get_val_as_string(const struct abstract_type *, void *, char *); 24.25 + 24.26 24.27 void 24.28 xen_init(void) 24.29 @@ -1174,37 +1179,12 @@ add_struct_value(const struct abstract_t 24.30 switch (type->typename) 24.31 { 24.32 case REF: 24.33 + case STRING: 24.34 + case INT: 24.35 + case ENUM: 24.36 { 24.37 - arbitrary_record_opt *val = *(arbitrary_record_opt **)value; 24.38 - if (val != NULL) 24.39 - { 24.40 - if (val->is_record) 24.41 - { 24.42 - adder(node, key, "string", val->u.record->handle); 24.43 - } 24.44 - else 24.45 - { 24.46 - adder(node, key, "string", val->u.handle); 24.47 - } 24.48 - } 24.49 - } 24.50 - break; 24.51 - 24.52 - case STRING: 24.53 - { 24.54 - char *val = *(char **)value; 24.55 - if (val != NULL) 24.56 - { 24.57 - adder(node, key, "string", val); 24.58 - } 24.59 - } 24.60 - break; 24.61 - 24.62 - case INT: 24.63 - { 24.64 - int64_t val = *(int64_t *)value; 24.65 - snprintf(buf, sizeof(buf), "%"PRId64, val); 24.66 - adder(node, key, "string", buf); 24.67 + const char *val_as_string = get_val_as_string(type, value, buf); 24.68 + adder(node, key, "string", val_as_string); 24.69 } 24.70 break; 24.71 24.72 @@ -1223,13 +1203,6 @@ add_struct_value(const struct abstract_t 24.73 } 24.74 break; 24.75 24.76 - case ENUM: 24.77 - { 24.78 - int val = *(int *)value; 24.79 - adder(node, key, "string", type->enum_marshaller(val)); 24.80 - } 24.81 - break; 24.82 - 24.83 case SET: 24.84 { 24.85 const struct abstract_type *member_type = type->child; 24.86 @@ -1251,12 +1224,95 @@ add_struct_value(const struct abstract_t 24.87 break; 24.88 24.89 case STRUCT: 24.90 - case MAP: 24.91 { 24.92 + assert(false); 24.93 /* XXX Nested structures aren't supported yet, but 24.94 fortunately we don't need them, because we don't have 24.95 any "deep create" calls. This will need to be 24.96 - fixed. We don't need maps either. */ 24.97 + fixed. */ 24.98 + } 24.99 + break; 24.100 + 24.101 + case MAP: 24.102 + { 24.103 + size_t member_size = type->struct_size; 24.104 + const struct abstract_type *l_type = type->members[0].type; 24.105 + const struct abstract_type *r_type = type->members[1].type; 24.106 + int l_offset = type->members[0].offset; 24.107 + int r_offset = type->members[1].offset; 24.108 + 24.109 + arbitrary_map *map_val = *(arbitrary_map **)value; 24.110 + 24.111 + if (map_val != NULL) 24.112 + { 24.113 + xmlNode *struct_node = add_nested_struct(node, key); 24.114 + 24.115 + for (size_t i = 0; i < map_val->size; i++) 24.116 + { 24.117 + void *contents = (void *)map_val->contents; 24.118 + void *l_value = contents + (i * member_size) + l_offset; 24.119 + void *r_value = contents + (i * member_size) + r_offset; 24.120 + 24.121 + const char *l_value_as_string = 24.122 + get_val_as_string(l_type, l_value, buf); 24.123 + 24.124 + add_struct_value(r_type, r_value, add_struct_member, 24.125 + l_value_as_string, struct_node); 24.126 + } 24.127 + } 24.128 + } 24.129 + break; 24.130 + 24.131 + default: 24.132 + assert(false); 24.133 + } 24.134 +} 24.135 + 24.136 + 24.137 +static const char * 24.138 +get_val_as_string(const struct abstract_type *type, void *value, char *buf) 24.139 +{ 24.140 + switch (type->typename) 24.141 + { 24.142 + case REF: 24.143 + { 24.144 + arbitrary_record_opt *val = *(arbitrary_record_opt **)value; 24.145 + if (val != NULL) 24.146 + { 24.147 + if (val->is_record) 24.148 + { 24.149 + return val->u.record->handle; 24.150 + } 24.151 + else 24.152 + { 24.153 + return val->u.handle; 24.154 + } 24.155 + } 24.156 + else 24.157 + { 24.158 + return NULL; 24.159 + } 24.160 + } 24.161 + break; 24.162 + 24.163 + case STRING: 24.164 + { 24.165 + return *(char **)value; 24.166 + } 24.167 + break; 24.168 + 24.169 + case INT: 24.170 + { 24.171 + int64_t val = *(int64_t *)value; 24.172 + snprintf(buf, sizeof(buf), "%"PRId64, val); 24.173 + return buf; 24.174 + } 24.175 + break; 24.176 + 24.177 + case ENUM: 24.178 + { 24.179 + int val = *(int *)value; 24.180 + return type->enum_marshaller(val); 24.181 } 24.182 break; 24.183 24.184 @@ -1331,7 +1387,19 @@ add_struct_array(xmlNode *struct_node, c 24.185 xmlNode *array_node = add_container(value_node, "array"); 24.186 24.187 return add_container(array_node, "data"); 24.188 +} 24.189 24.190 + 24.191 +static xmlNode * 24.192 +add_nested_struct(xmlNode *struct_node, const char *name) 24.193 +{ 24.194 + xmlNode *member_node = add_container(struct_node, "member"); 24.195 + 24.196 + xmlNewChild(member_node, NULL, BAD_CAST "name", BAD_CAST name); 24.197 + 24.198 + xmlNode *value_node = add_container(member_node, "value"); 24.199 + 24.200 + return add_container(value_node, "struct"); 24.201 } 24.202 24.203
25.1 --- a/tools/libxen/src/xen_host.c Sun Feb 04 12:18:48 2007 -0700 25.2 +++ b/tools/libxen/src/xen_host.c Sun Feb 04 12:24:53 2007 -0700 25.3 @@ -632,6 +632,23 @@ xen_host_reboot(xen_session *session, xe 25.4 25.5 25.6 bool 25.7 +xen_host_dmesg(xen_session *session, char **result, xen_host host) 25.8 +{ 25.9 + abstract_value param_values[] = 25.10 + { 25.11 + { .type = &abstract_type_string, 25.12 + .u.string_val = host } 25.13 + }; 25.14 + 25.15 + abstract_type result_type = abstract_type_string; 25.16 + 25.17 + *result = NULL; 25.18 + XEN_CALL_("host.dmesg"); 25.19 + return session->ok; 25.20 +} 25.21 + 25.22 + 25.23 +bool 25.24 xen_host_get_all(xen_session *session, struct xen_host_set **result) 25.25 { 25.26
26.1 --- a/tools/libxen/src/xen_int_float_map.c Sun Feb 04 12:18:48 2007 -0700 26.2 +++ b/tools/libxen/src/xen_int_float_map.c Sun Feb 04 12:24:53 2007 -0700 26.3 @@ -25,8 +25,10 @@ 26.4 xen_int_float_map * 26.5 xen_int_float_map_alloc(size_t size) 26.6 { 26.7 - return calloc(1, sizeof(xen_int_float_map) + 26.8 - size * sizeof(struct xen_int_float_map_contents)); 26.9 + xen_int_float_map *result = calloc(1, sizeof(xen_int_float_map) + 26.10 + size * sizeof(struct xen_int_float_map_contents)); 26.11 + result->size = size; 26.12 + return result; 26.13 } 26.14 26.15
27.1 --- a/tools/libxen/src/xen_string_string_map.c Sun Feb 04 12:18:48 2007 -0700 27.2 +++ b/tools/libxen/src/xen_string_string_map.c Sun Feb 04 12:24:53 2007 -0700 27.3 @@ -25,8 +25,10 @@ 27.4 xen_string_string_map * 27.5 xen_string_string_map_alloc(size_t size) 27.6 { 27.7 - return calloc(1, sizeof(xen_string_string_map) + 27.8 - size * sizeof(struct xen_string_string_map_contents)); 27.9 + xen_string_string_map *result = calloc(1, sizeof(xen_string_string_map) + 27.10 + size * sizeof(struct xen_string_string_map_contents)); 27.11 + result->size = size; 27.12 + return result; 27.13 } 27.14 27.15
28.1 --- a/tools/libxen/src/xen_vdi.c Sun Feb 04 12:18:48 2007 -0700 28.2 +++ b/tools/libxen/src/xen_vdi.c Sun Feb 04 12:24:53 2007 -0700 28.3 @@ -67,6 +67,9 @@ static const struct_member xen_vdi_recor 28.4 { .key = "sector_size", 28.5 .type = &abstract_type_int, 28.6 .offset = offsetof(xen_vdi_record, sector_size) }, 28.7 + { .key = "location", 28.8 + .type = &abstract_type_string, 28.9 + .offset = offsetof(xen_vdi_record, location) }, 28.10 { .key = "type", 28.11 .type = &xen_vdi_type_abstract_type_, 28.12 .offset = offsetof(xen_vdi_record, type) },
29.1 --- a/tools/libxen/src/xen_vm.c Sun Feb 04 12:18:48 2007 -0700 29.2 +++ b/tools/libxen/src/xen_vm.c Sun Feb 04 12:24:53 2007 -0700 29.3 @@ -145,9 +145,12 @@ static const struct_member xen_vm_record 29.4 { .key = "PV_bootloader_args", 29.5 .type = &abstract_type_string, 29.6 .offset = offsetof(xen_vm_record, pv_bootloader_args) }, 29.7 - { .key = "HVM_boot", 29.8 + { .key = "HVM_boot_policy", 29.9 .type = &abstract_type_string, 29.10 - .offset = offsetof(xen_vm_record, hvm_boot) }, 29.11 + .offset = offsetof(xen_vm_record, hvm_boot_policy) }, 29.12 + { .key = "HVM_boot_params", 29.13 + .type = &abstract_type_string_string_map, 29.14 + .offset = offsetof(xen_vm_record, hvm_boot_params) }, 29.15 { .key = "platform_std_VGA", 29.16 .type = &abstract_type_bool, 29.17 .offset = offsetof(xen_vm_record, platform_std_vga) }, 29.18 @@ -216,7 +219,8 @@ xen_vm_record_free(xen_vm_record *record 29.19 free(record->pv_ramdisk); 29.20 free(record->pv_args); 29.21 free(record->pv_bootloader_args); 29.22 - free(record->hvm_boot); 29.23 + free(record->hvm_boot_policy); 29.24 + xen_string_string_map_free(record->hvm_boot_params); 29.25 free(record->platform_serial); 29.26 free(record->pci_bus); 29.27 xen_string_string_map_free(record->tools_version); 29.28 @@ -824,7 +828,7 @@ xen_vm_get_pv_bootloader_args(xen_sessio 29.29 29.30 29.31 bool 29.32 -xen_vm_get_hvm_boot(xen_session *session, char **result, xen_vm vm) 29.33 +xen_vm_get_hvm_boot_policy(xen_session *session, char **result, xen_vm vm) 29.34 { 29.35 abstract_value param_values[] = 29.36 { 29.37 @@ -835,7 +839,24 @@ xen_vm_get_hvm_boot(xen_session *session 29.38 abstract_type result_type = abstract_type_string; 29.39 29.40 *result = NULL; 29.41 - XEN_CALL_("VM.get_HVM_boot"); 29.42 + XEN_CALL_("VM.get_HVM_boot_policy"); 29.43 + return session->ok; 29.44 +} 29.45 + 29.46 + 29.47 +bool 29.48 +xen_vm_get_hvm_boot_params(xen_session *session, xen_string_string_map **result, xen_vm vm) 29.49 +{ 29.50 + abstract_value param_values[] = 29.51 + { 29.52 + { .type = &abstract_type_string, 29.53 + .u.string_val = vm } 29.54 + }; 29.55 + 29.56 + abstract_type result_type = abstract_type_string_string_map; 29.57 + 29.58 + *result = NULL; 29.59 + XEN_CALL_("VM.get_HVM_boot_params"); 29.60 return session->ok; 29.61 } 29.62 29.63 @@ -1376,17 +1397,67 @@ xen_vm_set_pv_bootloader_args(xen_sessio 29.64 29.65 29.66 bool 29.67 -xen_vm_set_hvm_boot(xen_session *session, xen_vm vm, char *boot) 29.68 +xen_vm_set_hvm_boot_policy(xen_session *session, xen_vm vm, char *boot_policy) 29.69 { 29.70 abstract_value param_values[] = 29.71 { 29.72 { .type = &abstract_type_string, 29.73 .u.string_val = vm }, 29.74 { .type = &abstract_type_string, 29.75 - .u.string_val = boot } 29.76 + .u.string_val = boot_policy } 29.77 + }; 29.78 + 29.79 + xen_call_(session, "VM.set_HVM_boot_policy", param_values, 2, NULL, NULL); 29.80 + return session->ok; 29.81 +} 29.82 + 29.83 + 29.84 +bool 29.85 +xen_vm_set_hvm_boot_params(xen_session *session, xen_vm vm, xen_string_string_map *boot_params) 29.86 +{ 29.87 + abstract_value param_values[] = 29.88 + { 29.89 + { .type = &abstract_type_string, 29.90 + .u.string_val = vm }, 29.91 + { .type = &abstract_type_string_string_map, 29.92 + .u.set_val = (arbitrary_set *)boot_params } 29.93 }; 29.94 29.95 - xen_call_(session, "VM.set_HVM_boot", param_values, 2, NULL, NULL); 29.96 + xen_call_(session, "VM.set_HVM_boot_params", param_values, 2, NULL, NULL); 29.97 + return session->ok; 29.98 +} 29.99 + 29.100 + 29.101 +bool 29.102 +xen_vm_add_to_hvm_boot_params(xen_session *session, xen_vm vm, char *key, char *value) 29.103 +{ 29.104 + abstract_value param_values[] = 29.105 + { 29.106 + { .type = &abstract_type_string, 29.107 + .u.string_val = vm }, 29.108 + { .type = &abstract_type_string, 29.109 + .u.string_val = key }, 29.110 + { .type = &abstract_type_string, 29.111 + .u.string_val = value } 29.112 + }; 29.113 + 29.114 + xen_call_(session, "VM.add_to_HVM_boot_params", param_values, 3, NULL, NULL); 29.115 + return session->ok; 29.116 +} 29.117 + 29.118 + 29.119 +bool 29.120 +xen_vm_remove_from_hvm_boot_params(xen_session *session, xen_vm vm, char *key) 29.121 +{ 29.122 + abstract_value param_values[] = 29.123 + { 29.124 + { .type = &abstract_type_string, 29.125 + .u.string_val = vm }, 29.126 + { .type = &abstract_type_string, 29.127 + .u.string_val = key } 29.128 + }; 29.129 + 29.130 + xen_call_(session, "VM.remove_from_HVM_boot_params", param_values, 2, NULL, NULL); 29.131 return session->ok; 29.132 } 29.133
30.1 --- a/tools/libxen/src/xen_vm_power_state.c Sun Feb 04 12:18:48 2007 -0700 30.2 +++ b/tools/libxen/src/xen_vm_power_state.c Sun Feb 04 12:24:53 2007 -0700 30.3 @@ -32,7 +32,6 @@ static const char *lookup_table[] = 30.4 "Paused", 30.5 "Running", 30.6 "Suspended", 30.7 - "ShuttingDown", 30.8 "Unknown" 30.9 }; 30.10
31.1 --- a/tools/libxen/test/test_bindings.c Sun Feb 04 12:18:48 2007 -0700 31.2 +++ b/tools/libxen/test/test_bindings.c Sun Feb 04 12:24:53 2007 -0700 31.3 @@ -1,5 +1,5 @@ 31.4 /* 31.5 - * Copyright (c) 2006 XenSource, Inc. 31.6 + * Copyright (c) 2006-2007 XenSource, Inc. 31.7 * 31.8 * This library is free software; you can redistribute it and/or 31.9 * modify it under the terms of the GNU Lesser General Public 31.10 @@ -29,6 +29,7 @@ 31.11 #include "xen_sr.h" 31.12 #include "xen_vbd.h" 31.13 #include "xen_vdi.h" 31.14 +#include "xen_console.h" 31.15 #include "xen_vm.h" 31.16 31.17 31.18 @@ -58,7 +59,7 @@ typedef struct 31.19 } xen_comms; 31.20 31.21 31.22 -static xen_vm create_new_vm(xen_session *session); 31.23 +static xen_vm create_new_vm(xen_session *session, bool hvm); 31.24 static void print_vm_power_state(xen_session *session, xen_vm vm); 31.25 31.26 31.27 @@ -205,6 +206,20 @@ int main(int argc, char **argv) 31.28 return 1; 31.29 } 31.30 31.31 + char *dmesg; 31.32 + if (!xen_host_dmesg(session, &dmesg, host)) 31.33 + { 31.34 + print_error(session); 31.35 + xen_string_string_map_free(versions); 31.36 + xen_host_free(host); 31.37 + xen_vm_record_free(vm_record); 31.38 + xen_uuid_bytes_free(vm_uuid_bytes); 31.39 + xen_uuid_free(vm_uuid); 31.40 + xen_vm_free(vm); 31.41 + CLEANUP; 31.42 + return 1; 31.43 + } 31.44 + 31.45 printf("%s.\n", vm_uuid); 31.46 31.47 fprintf(stderr, "In bytes, the VM UUID is "); 31.48 @@ -222,6 +237,8 @@ int main(int argc, char **argv) 31.49 versions->contents[i].val); 31.50 } 31.51 31.52 + printf("Host dmesg follows:\n%s\n\n", dmesg); 31.53 + 31.54 printf("%s.\n", vm_record->uuid); 31.55 31.56 printf("Resident on %s.\n", (char *)vm_record->resident_on->u.handle); 31.57 @@ -243,9 +260,10 @@ int main(int argc, char **argv) 31.58 31.59 xen_host_free(host); 31.60 xen_string_string_map_free(versions); 31.61 + free(dmesg); 31.62 31.63 31.64 - xen_vm new_vm = create_new_vm(session); 31.65 + xen_vm new_vm = create_new_vm(session, true); 31.66 if (!session->ok) 31.67 { 31.68 /* Error has been logged, just clean up. */ 31.69 @@ -275,13 +293,28 @@ int main(int argc, char **argv) 31.70 * allocation patterns can be used, as long as the allocation and free are 31.71 * paired correctly. 31.72 */ 31.73 -static xen_vm create_new_vm(xen_session *session) 31.74 +static xen_vm create_new_vm(xen_session *session, bool hvm) 31.75 { 31.76 xen_string_string_map *vcpus_params = xen_string_string_map_alloc(1); 31.77 + vcpus_params->contents[0].key = strdup("weight"); 31.78 + vcpus_params->contents[0].val = strdup("300"); 31.79 + 31.80 + xen_string_string_map *hvm_boot_params; 31.81 + if (hvm) 31.82 + { 31.83 + hvm_boot_params = xen_string_string_map_alloc(1); 31.84 + hvm_boot_params->contents[0].key = strdup("order"); 31.85 + hvm_boot_params->contents[0].val = strdup("cd"); 31.86 + } 31.87 + else 31.88 + { 31.89 + hvm_boot_params = NULL; 31.90 + } 31.91 + 31.92 xen_vm_record vm_record = 31.93 { 31.94 - .name_label = "NewVM", 31.95 - .name_description = "New VM Description", 31.96 + .name_label = hvm ? "NewHVM" : "NewPV", 31.97 + .name_description = hvm ? "New HVM VM" : "New PV VM", 31.98 .user_version = 1, 31.99 .is_a_template = false, 31.100 .memory_static_max = 256, 31.101 @@ -294,18 +327,18 @@ static xen_vm create_new_vm(xen_session 31.102 .actions_after_shutdown = XEN_ON_NORMAL_EXIT_DESTROY, 31.103 .actions_after_reboot = XEN_ON_NORMAL_EXIT_RESTART, 31.104 .actions_after_crash = XEN_ON_CRASH_BEHAVIOUR_PRESERVE, 31.105 - .hvm_boot = "", 31.106 - .pv_bootloader = "pygrub", 31.107 - .pv_kernel = "/boot/vmlinuz-2.6.16.33-xen", 31.108 - .pv_ramdisk = "", 31.109 - .pv_args = "", 31.110 - .pv_bootloader_args = "" 31.111 + .hvm_boot_policy = hvm ? "BIOS order" : NULL, 31.112 + .hvm_boot_params = hvm ? hvm_boot_params : NULL, 31.113 + .pv_bootloader = hvm ? NULL : "pygrub", 31.114 + .pv_kernel = hvm ? NULL : "/boot/vmlinuz-2.6.16.33-xen", 31.115 }; 31.116 31.117 - 31.118 xen_vm vm; 31.119 xen_vm_create(session, &vm, &vm_record); 31.120 31.121 + xen_string_string_map_free(vcpus_params); 31.122 + xen_string_string_map_free(hvm_boot_params); 31.123 + 31.124 if (!session->ok) 31.125 { 31.126 fprintf(stderr, "VM creation failed.\n"); 31.127 @@ -368,7 +401,8 @@ static xen_vm create_new_vm(xen_session 31.128 .vm = &vm_record_opt, 31.129 .vdi = &vdi0_record_opt, 31.130 .device = "xvda1", 31.131 - .mode = XEN_VBD_MODE_RW 31.132 + .mode = XEN_VBD_MODE_RW, 31.133 + .bootable = 1, 31.134 }; 31.135 31.136 xen_vbd vbd0; 31.137 @@ -383,13 +417,38 @@ static xen_vm create_new_vm(xen_session 31.138 return NULL; 31.139 } 31.140 31.141 + xen_console vnc_console = NULL; 31.142 + if (hvm) { 31.143 + xen_console_record vnc_console_record = 31.144 + { 31.145 + .protocol = XEN_CONSOLE_PROTOCOL_RFB, 31.146 + .vm = &vm_record_opt, 31.147 + }; 31.148 + 31.149 + if (!xen_console_create(session, &vnc_console, &vnc_console_record)) 31.150 + { 31.151 + fprintf(stderr, "VNC console creation failed.\n"); 31.152 + print_error(session); 31.153 + 31.154 + xen_vbd_free(vbd0); 31.155 + xen_vdi_free(vdi0); 31.156 + xen_sr_set_free(srs); 31.157 + xen_vm_free(vm); 31.158 + return NULL; 31.159 + } 31.160 + } 31.161 + 31.162 char *vm_uuid; 31.163 char *vdi0_uuid; 31.164 char *vbd0_uuid; 31.165 + char *vnc_uuid = NULL; 31.166 31.167 xen_vm_get_uuid(session, &vm_uuid, vm); 31.168 xen_vdi_get_uuid(session, &vdi0_uuid, vdi0); 31.169 xen_vbd_get_uuid(session, &vbd0_uuid, vbd0); 31.170 + if (hvm) { 31.171 + xen_console_get_uuid(session, &vnc_uuid, vnc_console); 31.172 + } 31.173 31.174 if (!session->ok) 31.175 { 31.176 @@ -399,22 +458,35 @@ static xen_vm create_new_vm(xen_session 31.177 xen_uuid_free(vm_uuid); 31.178 xen_uuid_free(vdi0_uuid); 31.179 xen_uuid_free(vbd0_uuid); 31.180 + xen_uuid_free(vnc_uuid); 31.181 xen_vbd_free(vbd0); 31.182 xen_vdi_free(vdi0); 31.183 + xen_console_free(vnc_console); 31.184 xen_sr_set_free(srs); 31.185 xen_vm_free(vm); 31.186 return NULL; 31.187 } 31.188 31.189 - fprintf(stderr, 31.190 - "Created a new VM, with UUID %s, VDI UUID %s, and VBD UUID %s.\n", 31.191 - vm_uuid, vdi0_uuid, vbd0_uuid); 31.192 + if (hvm) { 31.193 + fprintf(stderr, 31.194 + "Created a new HVM VM, with UUID %s, VDI UUID %s, VBD " 31.195 + "UUID %s, and VNC console UUID %s.\n", 31.196 + vm_uuid, vdi0_uuid, vbd0_uuid, vnc_uuid); 31.197 + } 31.198 + else { 31.199 + fprintf(stderr, 31.200 + "Created a new PV VM, with UUID %s, VDI UUID %s, and VBD " 31.201 + "UUID %s.\n", 31.202 + vm_uuid, vdi0_uuid, vbd0_uuid); 31.203 + } 31.204 31.205 xen_uuid_free(vm_uuid); 31.206 xen_uuid_free(vdi0_uuid); 31.207 xen_uuid_free(vbd0_uuid); 31.208 + xen_uuid_free(vnc_uuid); 31.209 xen_vbd_free(vbd0); 31.210 xen_vdi_free(vdi0); 31.211 + xen_console_free(vnc_console); 31.212 xen_sr_set_free(srs); 31.213 31.214 return vm;
32.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 32.2 +++ b/tools/libxen/test/test_hvm_bindings.c Sun Feb 04 12:24:53 2007 -0700 32.3 @@ -0,0 +1,445 @@ 32.4 +/* 32.5 + * Copyright (c) 2006 XenSource, Inc. 32.6 + * 32.7 + * This library is free software; you can redistribute it and/or 32.8 + * modify it under the terms of the GNU Lesser General Public 32.9 + * License as published by the Free Software Foundation; either 32.10 + * version 2.1 of the License, or (at your option) any later version. 32.11 + * 32.12 + * This library is distributed in the hope that it will be useful, 32.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 32.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 32.15 + * Lesser General Public License for more details. 32.16 + * 32.17 + * You should have received a copy of the GNU Lesser General Public 32.18 + * License along with this library; if not, write to the Free Software 32.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 32.20 + */ 32.21 + 32.22 +#define _GNU_SOURCE 32.23 +#include <inttypes.h> 32.24 +#include <stdlib.h> 32.25 +#include <stdio.h> 32.26 +#include <string.h> 32.27 + 32.28 +#include <libxml/parser.h> 32.29 +#include <curl/curl.h> 32.30 + 32.31 +#include "xen_host.h" 32.32 +#include "xen_sr.h" 32.33 +#include "xen_vbd.h" 32.34 +#include "xen_vdi.h" 32.35 +#include "xen_vm.h" 32.36 + 32.37 + 32.38 +static void usage() 32.39 +{ 32.40 + fprintf(stderr, 32.41 +"Usage:\n" 32.42 +"\n" 32.43 +" test_bindings <url> <username> <password>\n" 32.44 +"\n" 32.45 +"where\n" 32.46 +" <url> is a fragment of the server's URL, e.g. localhost:8005/RPC2;\n" 32.47 +" <username> is the username to use at the server; and\n" 32.48 +" <password> is the password.\n"); 32.49 + 32.50 + exit(EXIT_FAILURE); 32.51 +} 32.52 + 32.53 + 32.54 +static char *url; 32.55 + 32.56 + 32.57 +typedef struct 32.58 +{ 32.59 + xen_result_func func; 32.60 + void *handle; 32.61 +} xen_comms; 32.62 + 32.63 + 32.64 +static xen_vm create_new_vm(xen_session *session); 32.65 +static void print_vm_power_state(xen_session *session, xen_vm vm); 32.66 + 32.67 + 32.68 +static size_t 32.69 +write_func(void *ptr, size_t size, size_t nmemb, xen_comms *comms) 32.70 +{ 32.71 + size_t n = size * nmemb; 32.72 + return comms->func(ptr, n, comms->handle) ? n : 0; 32.73 +} 32.74 + 32.75 + 32.76 +static int 32.77 +call_func(const void *data, size_t len, void *user_handle, 32.78 + void *result_handle, xen_result_func result_func) 32.79 +{ 32.80 + (void)user_handle; 32.81 + 32.82 + CURL *curl = curl_easy_init(); 32.83 + if (!curl) { 32.84 + return -1; 32.85 + } 32.86 + 32.87 + xen_comms comms = { 32.88 + .func = result_func, 32.89 + .handle = result_handle 32.90 + }; 32.91 + 32.92 + curl_easy_setopt(curl, CURLOPT_URL, url); 32.93 + curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1); 32.94 + curl_easy_setopt(curl, CURLOPT_MUTE, 1); 32.95 + curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &write_func); 32.96 + curl_easy_setopt(curl, CURLOPT_WRITEDATA, &comms); 32.97 + curl_easy_setopt(curl, CURLOPT_POST, 1); 32.98 + curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data); 32.99 + curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, len); 32.100 + 32.101 + CURLcode result = curl_easy_perform(curl); 32.102 + 32.103 + curl_easy_cleanup(curl); 32.104 + 32.105 + return result; 32.106 +} 32.107 + 32.108 + 32.109 +static void print_error(xen_session *session) 32.110 +{ 32.111 + fprintf(stderr, "Error: %d", session->error_description_count); 32.112 + for (int i = 0; i < session->error_description_count; i++) 32.113 + { 32.114 + fprintf(stderr, "%s ", session->error_description[i]); 32.115 + } 32.116 + fprintf(stderr, "\n"); 32.117 +} 32.118 + 32.119 + 32.120 +int main(int argc, char **argv) 32.121 +{ 32.122 + if (argc != 4) 32.123 + { 32.124 + usage(); 32.125 + } 32.126 + 32.127 + url = argv[1]; 32.128 + char *username = argv[2]; 32.129 + char *password = argv[3]; 32.130 + 32.131 + xmlInitParser(); 32.132 + xen_init(); 32.133 + curl_global_init(CURL_GLOBAL_ALL); 32.134 + 32.135 +#define CLEANUP \ 32.136 + do { \ 32.137 + xen_session_logout(session); \ 32.138 + curl_global_cleanup(); \ 32.139 + xen_fini(); \ 32.140 + xmlCleanupParser(); \ 32.141 + } while(0) \ 32.142 + 32.143 + 32.144 + xen_session *session = 32.145 + xen_session_login_with_password(call_func, NULL, username, password); 32.146 + 32.147 + xen_vm vm; 32.148 + if (!xen_vm_get_by_uuid(session, &vm, 32.149 + "00000000-0000-0000-0000-000000000000")) 32.150 + { 32.151 + print_error(session); 32.152 + CLEANUP; 32.153 + return 1; 32.154 + } 32.155 + 32.156 + char *vm_uuid; 32.157 + if (!xen_vm_get_uuid(session, &vm_uuid, vm)) 32.158 + { 32.159 + print_error(session); 32.160 + xen_vm_free(vm); 32.161 + CLEANUP; 32.162 + return 1; 32.163 + } 32.164 + 32.165 + char *vm_uuid_bytes; 32.166 + if (!xen_uuid_string_to_bytes(vm_uuid, &vm_uuid_bytes)) 32.167 + { 32.168 + fprintf(stderr, "xen_uuid_string_to_bytes failed.\n"); 32.169 + xen_uuid_free(vm_uuid); 32.170 + xen_vm_free(vm); 32.171 + CLEANUP; 32.172 + return 1; 32.173 + } 32.174 + 32.175 + xen_vm_record *vm_record; 32.176 + if (!xen_vm_get_record(session, &vm_record, vm)) 32.177 + { 32.178 + print_error(session); 32.179 + xen_uuid_bytes_free(vm_uuid_bytes); 32.180 + xen_uuid_free(vm_uuid); 32.181 + xen_vm_free(vm); 32.182 + CLEANUP; 32.183 + return 1; 32.184 + } 32.185 + 32.186 + xen_host host; 32.187 + if (!xen_session_get_this_host(session, &host)) 32.188 + { 32.189 + print_error(session); 32.190 + xen_vm_record_free(vm_record); 32.191 + xen_uuid_bytes_free(vm_uuid_bytes); 32.192 + xen_uuid_free(vm_uuid); 32.193 + xen_vm_free(vm); 32.194 + CLEANUP; 32.195 + return 1; 32.196 + } 32.197 + 32.198 + xen_string_string_map *versions; 32.199 + if (!xen_host_get_software_version(session, &versions, host)) 32.200 + { 32.201 + print_error(session); 32.202 + xen_host_free(host); 32.203 + xen_vm_record_free(vm_record); 32.204 + xen_uuid_bytes_free(vm_uuid_bytes); 32.205 + xen_uuid_free(vm_uuid); 32.206 + xen_vm_free(vm); 32.207 + CLEANUP; 32.208 + return 1; 32.209 + } 32.210 + 32.211 + printf("%s.\n", vm_uuid); 32.212 + 32.213 + fprintf(stderr, "In bytes, the VM UUID is "); 32.214 + for (int i = 0; i < 15; i++) 32.215 + { 32.216 + fprintf(stderr, "%x, ", (unsigned int)vm_uuid_bytes[i]); 32.217 + } 32.218 + fprintf(stderr, "%x.\n", (unsigned int)vm_uuid_bytes[15]); 32.219 + 32.220 + printf("%zd.\n", versions->size); 32.221 + 32.222 + for (size_t i = 0; i < versions->size; i++) 32.223 + { 32.224 + printf("%s -> %s.\n", versions->contents[i].key, 32.225 + versions->contents[i].val); 32.226 + } 32.227 + 32.228 + printf("%s.\n", vm_record->uuid); 32.229 + 32.230 + printf("Resident on %s.\n", (char *)vm_record->resident_on->u.handle); 32.231 + 32.232 + printf("%s.\n", xen_vm_power_state_to_string(vm_record->power_state)); 32.233 + 32.234 + for (size_t i = 0; i < vm_record->vcpus_utilisation->size; i++) 32.235 + { 32.236 + printf("%"PRId64" -> %lf.\n", 32.237 + vm_record->vcpus_utilisation->contents[i].key, 32.238 + vm_record->vcpus_utilisation->contents[i].val); 32.239 + } 32.240 + 32.241 + xen_uuid_bytes_free(vm_uuid_bytes); 32.242 + xen_uuid_free(vm_uuid); 32.243 + xen_vm_free(vm); 32.244 + 32.245 + xen_vm_record_free(vm_record); 32.246 + 32.247 + xen_host_free(host); 32.248 + xen_string_string_map_free(versions); 32.249 + 32.250 + 32.251 + xen_vm new_vm = create_new_vm(session); 32.252 + if (!session->ok) 32.253 + { 32.254 + /* Error has been logged, just clean up. */ 32.255 + CLEANUP; 32.256 + return 1; 32.257 + } 32.258 + 32.259 + print_vm_power_state(session, new_vm); 32.260 + if (!session->ok) 32.261 + { 32.262 + /* Error has been logged, just clean up. */ 32.263 + xen_vm_free(new_vm); 32.264 + CLEANUP; 32.265 + return 1; 32.266 + } 32.267 + 32.268 + xen_vm_free(new_vm); 32.269 + CLEANUP; 32.270 + 32.271 + return 0; 32.272 +} 32.273 + 32.274 + 32.275 +/** 32.276 + * Creation of a new VM, using the Named Parameters idiom. Allocate the 32.277 + * xen_vm_record here, but the sets through the library. Either 32.278 + * allocation patterns can be used, as long as the allocation and free are 32.279 + * paired correctly. 32.280 + */ 32.281 +static xen_vm create_new_vm(xen_session *session) 32.282 +{ 32.283 + xen_string_string_map *vcpus_params = xen_string_string_map_alloc(1); 32.284 + xen_vm_record vm_record = 32.285 + { 32.286 + .name_label = "NewHVM", 32.287 + .name_description = "New HVM Description", 32.288 + .user_version = 1, 32.289 + .is_a_template = false, 32.290 + .memory_static_max = 256, 32.291 + .memory_dynamic_max = 256, 32.292 + .memory_dynamic_min = 128, 32.293 + .memory_static_min = 128, 32.294 + .vcpus_policy = "credit", 32.295 + .vcpus_params = vcpus_params, 32.296 + .vcpus_number = 2, 32.297 + .actions_after_shutdown = XEN_ON_NORMAL_EXIT_DESTROY, 32.298 + .actions_after_reboot = XEN_ON_NORMAL_EXIT_RESTART, 32.299 + .actions_after_crash = XEN_ON_CRASH_BEHAVIOUR_PRESERVE, 32.300 + .hvm_boot = "cda", 32.301 + }; 32.302 + 32.303 + 32.304 + xen_vm vm; 32.305 + xen_vm_create(session, &vm, &vm_record); 32.306 + 32.307 + if (!session->ok) 32.308 + { 32.309 + fprintf(stderr, "VM creation failed.\n"); 32.310 + print_error(session); 32.311 + return NULL; 32.312 + } 32.313 + 32.314 + 32.315 + /* 32.316 + * Create a new disk for the new VM. 32.317 + */ 32.318 + xen_sr_set *srs; 32.319 + if (!xen_sr_get_by_name_label(session, &srs, "Local") || 32.320 + srs->size < 1) 32.321 + { 32.322 + fprintf(stderr, "SR lookup failed.\n"); 32.323 + print_error(session); 32.324 + xen_vm_free(vm); 32.325 + return NULL; 32.326 + } 32.327 + 32.328 + xen_sr_record_opt sr_record = 32.329 + { 32.330 + .u.handle = srs->contents[0] 32.331 + }; 32.332 + xen_vdi_record vdi0_record = 32.333 + { 32.334 + .name_label = "MyRootFS", 32.335 + .name_description = "MyRootFS description", 32.336 + .sr = &sr_record, 32.337 + .virtual_size = (1 << 21), // 1GiB / 512 bytes/sector 32.338 + .sector_size = 512, 32.339 + .location = "file:/root/gentoo.amd64.hvm.img", 32.340 + .type = XEN_VDI_TYPE_SYSTEM, 32.341 + .sharable = false, 32.342 + .read_only = false 32.343 + }; 32.344 + 32.345 + xen_vdi vdi0; 32.346 + if (!xen_vdi_create(session, &vdi0, &vdi0_record)) 32.347 + { 32.348 + fprintf(stderr, "VDI creation failed.\n"); 32.349 + print_error(session); 32.350 + 32.351 + xen_sr_set_free(srs); 32.352 + xen_vm_free(vm); 32.353 + return NULL; 32.354 + } 32.355 + 32.356 + 32.357 + xen_vm_record_opt vm_record_opt = 32.358 + { 32.359 + .u.handle = vm 32.360 + }; 32.361 + xen_vdi_record_opt vdi0_record_opt = 32.362 + { 32.363 + .u.handle = vdi0 32.364 + }; 32.365 + xen_vbd_record vbd0_record = 32.366 + { 32.367 + .vm = &vm_record_opt, 32.368 + .vdi = &vdi0_record_opt, 32.369 + .device = "xvda1", 32.370 + .mode = XEN_VBD_MODE_RW 32.371 + }; 32.372 + 32.373 + xen_vbd vbd0; 32.374 + if (!xen_vbd_create(session, &vbd0, &vbd0_record)) 32.375 + { 32.376 + fprintf(stderr, "VBD creation failed.\n"); 32.377 + print_error(session); 32.378 + 32.379 + xen_vdi_free(vdi0); 32.380 + xen_sr_set_free(srs); 32.381 + xen_vm_free(vm); 32.382 + return NULL; 32.383 + } 32.384 + 32.385 + char *vm_uuid; 32.386 + char *vdi0_uuid; 32.387 + char *vbd0_uuid; 32.388 + 32.389 + xen_vm_get_uuid(session, &vm_uuid, vm); 32.390 + xen_vdi_get_uuid(session, &vdi0_uuid, vdi0); 32.391 + xen_vbd_get_uuid(session, &vbd0_uuid, vbd0); 32.392 + 32.393 + if (!session->ok) 32.394 + { 32.395 + fprintf(stderr, "get_uuid call failed.\n"); 32.396 + print_error(session); 32.397 + 32.398 + xen_uuid_free(vm_uuid); 32.399 + xen_uuid_free(vdi0_uuid); 32.400 + xen_uuid_free(vbd0_uuid); 32.401 + xen_vbd_free(vbd0); 32.402 + xen_vdi_free(vdi0); 32.403 + xen_sr_set_free(srs); 32.404 + xen_vm_free(vm); 32.405 + return NULL; 32.406 + } 32.407 + 32.408 + fprintf(stderr, 32.409 + "Created a new VM, with UUID %s, VDI UUID %s, and VBD UUID %s.\n", 32.410 + vm_uuid, vdi0_uuid, vbd0_uuid); 32.411 + 32.412 + xen_uuid_free(vm_uuid); 32.413 + xen_uuid_free(vdi0_uuid); 32.414 + xen_uuid_free(vbd0_uuid); 32.415 + xen_vbd_free(vbd0); 32.416 + xen_vdi_free(vdi0); 32.417 + xen_sr_set_free(srs); 32.418 + 32.419 + return vm; 32.420 +} 32.421 + 32.422 + 32.423 +/** 32.424 + * Print the power state for the given VM. 32.425 + */ 32.426 +static void print_vm_power_state(xen_session *session, xen_vm vm) 32.427 +{ 32.428 + char *vm_uuid; 32.429 + enum xen_vm_power_state power_state; 32.430 + 32.431 + if (!xen_vm_get_uuid(session, &vm_uuid, vm)) 32.432 + { 32.433 + print_error(session); 32.434 + return; 32.435 + } 32.436 + 32.437 + if (!xen_vm_get_power_state(session, &power_state, vm)) 32.438 + { 32.439 + xen_uuid_free(vm_uuid); 32.440 + print_error(session); 32.441 + return; 32.442 + } 32.443 + 32.444 + printf("VM %s power state is %s.\n", vm_uuid, 32.445 + xen_vm_power_state_to_string(power_state)); 32.446 + 32.447 + xen_uuid_free(vm_uuid); 32.448 +}
33.1 --- a/tools/misc/Makefile Sun Feb 04 12:18:48 2007 -0700 33.2 +++ b/tools/misc/Makefile Sun Feb 04 12:24:53 2007 -0700 33.3 @@ -12,7 +12,7 @@ HDRS = $(wildcard *.h) 33.4 TARGETS = xenperf xc_shadow 33.5 33.6 INSTALL_BIN = $(TARGETS) xencons 33.7 -INSTALL_SBIN = netfix xm xen-bugtool xend xenperf 33.8 +INSTALL_SBIN = netfix xm xen-bugtool xen-python-path xend xenperf 33.9 33.10 .PHONY: all 33.11 all: build
34.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 34.2 +++ b/tools/misc/xen-python-path Sun Feb 04 12:24:53 2007 -0700 34.3 @@ -0,0 +1,41 @@ 34.4 +#!/usr/bin/env python 34.5 +# -*- mode: python; -*- 34.6 +#============================================================================ 34.7 +# This library is free software; you can redistribute it and/or 34.8 +# modify it under the terms of version 2.1 of the GNU Lesser General Public 34.9 +# License as published by the Free Software Foundation. 34.10 +# 34.11 +# This library is distributed in the hope that it will be useful, 34.12 +# but WITHOUT ANY WARRANTY; without even the implied warranty of 34.13 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 34.14 +# Lesser General Public License for more details. 34.15 +# 34.16 +# You should have received a copy of the GNU Lesser General Public 34.17 +# License along with this library; if not, write to the Free Software 34.18 +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 34.19 +#============================================================================ 34.20 +# Copyright (C) 2007 XenSource Inc. 34.21 +#============================================================================ 34.22 + 34.23 + 34.24 +# Use the auxbin module in Xend to determine the correct Python path. We 34.25 +# take the first installed instance of auxbin that we find, and then run it 34.26 +# to determine the correct path, appending that to sys.path. 34.27 + 34.28 +AUXBIN = 'xen/util/auxbin.py' 34.29 + 34.30 +import os 34.31 +import os.path 34.32 +import sys 34.33 + 34.34 +for p in ['python%s' % sys.version[:3], 'python']: 34.35 + for l in ['/usr/lib64', '/usr/lib']: 34.36 + d = os.path.join(l, p) 34.37 + if os.path.exists(os.path.join(d, AUXBIN)): 34.38 + sys.path.append(d) 34.39 + import xen.util.auxbin 34.40 + print os.path.join(xen.util.auxbin.libpath(), p) 34.41 + sys.exit(0) 34.42 + 34.43 +print >>sys.stderr, "Cannot find Xen Python modules." 34.44 +sys.exit(1)
35.1 --- a/tools/misc/xend Sun Feb 04 12:18:48 2007 -0700 35.2 +++ b/tools/misc/xend Sun Feb 04 12:24:53 2007 -0700 35.3 @@ -31,23 +31,13 @@ import signal 35.4 import time 35.5 import commands 35.6 35.7 - 35.8 -# Use the auxbin module in Xend to determine the correct Python path. We 35.9 -# take the first installed instance of auxbin that we find, and then run it 35.10 -# to determine the correct path, appending that to sys.path. 35.11 - 35.12 -AUXBIN = 'xen/util/auxbin.py' 35.13 +result = commands.getstatusoutput(os.path.join(os.path.dirname(sys.argv[0]), 35.14 + 'xen-python-path')) 35.15 +if result[0] != 0: 35.16 + print >>sys.stderr, result[1] 35.17 + sys.exit(1) 35.18 35.19 -for p in ['python%s' % sys.version[:3], 'python']: 35.20 - for l in ['/usr/lib64', '/usr/lib']: 35.21 - d = os.path.join(l, p) 35.22 - if os.path.exists(os.path.join(d, AUXBIN)): 35.23 - sys.path.append(d) 35.24 - import xen.util.auxbin 35.25 - libpath = os.path.join(xen.util.auxbin.libpath(), p) 35.26 - sys.path = sys.path[:-1] 35.27 - sys.path.append(libpath) 35.28 - break 35.29 +sys.path.append(result[1]) 35.30 35.31 from xen.xend.server import SrvDaemon 35.32
36.1 --- a/tools/pygrub/src/pygrub Sun Feb 04 12:18:48 2007 -0700 36.2 +++ b/tools/pygrub/src/pygrub Sun Feb 04 12:24:53 2007 -0700 36.3 @@ -197,7 +197,10 @@ class Grub: 36.4 self.screen = curses.initscr() 36.5 self.screen.timeout(1000) 36.6 if hasattr(curses, 'use_default_colors'): 36.7 - curses.use_default_colors() 36.8 + try: 36.9 + curses.use_default_colors() 36.10 + except: 36.11 + pass # Not important if we can't use colour 36.12 enable_cursor(False) 36.13 self.entry_win = curses.newwin(10, 74, 2, 1) 36.14 self.text_win = curses.newwin(10, 70, 12, 5)
37.1 --- a/tools/python/scripts/test_hvm_create.py Sun Feb 04 12:18:48 2007 -0700 37.2 +++ b/tools/python/scripts/test_hvm_create.py Sun Feb 04 12:24:53 2007 -0700 37.3 @@ -13,16 +13,11 @@ vm_cfg = { 37.4 37.5 37.6 'VCPUs_policy': 'credit', 37.7 - 'VCPUs_params': '', 37.8 + 'VCPUs_params': {}, 37.9 'VCPUs_number': 2, 37.10 - 'VCPUs_features_required': '', 37.11 - 'VCPUs_features_can_use': '', 37.12 - 'VCPUs_features_force_on': '', 37.13 - 'VCPUs_features_force_off': '', 37.14 37.15 'actions_after_shutdown': 'destroy', 37.16 'actions_after_reboot': 'restart', 37.17 - 'actions_after_suspend': 'destroy', 37.18 'actions_after_crash': 'destroy', 37.19 37.20 'PV_bootloader': '', 37.21 @@ -44,7 +39,7 @@ vm_cfg = { 37.22 local_vdi_cfg = { 37.23 'name_label': 'gentoo.hvm', 37.24 'name_description': '', 37.25 - 'uri': 'file:/root/gentoo.amd64.hvm.img', 37.26 + 'location': 'file:/root/gentoo.amd64.hvm.img', 37.27 'virtual_size': 0, 37.28 'sector_size': 0, 37.29 'type': 'system',
38.1 --- a/tools/python/scripts/test_vm_create.py Sun Feb 04 12:18:48 2007 -0700 38.2 +++ b/tools/python/scripts/test_vm_create.py Sun Feb 04 12:24:53 2007 -0700 38.3 @@ -15,14 +15,9 @@ vm_cfg = { 38.4 'VCPUs_policy': 'credit', 38.5 'VCPUs_params': '', 38.6 'VCPUs_number': 2, 38.7 - 'VCPUs_features_required': '', 38.8 - 'VCPUs_features_can_use': '', 38.9 - 'VCPUs_features_force_on': '', 38.10 - 'VCPUs_features_force_off': '', 38.11 38.12 'actions_after_shutdown': 'destroy', 38.13 'actions_after_reboot': 'restart', 38.14 - 'actions_after_suspend': 'destroy', 38.15 'actions_after_crash': 'destroy', 38.16 38.17 'PV_bootloader': '', 38.18 @@ -65,7 +60,7 @@ vbd_cfg = { 38.19 local_vdi_cfg = { 38.20 'name_label': 'gentoo.amd64.img', 38.21 'name_description': '', 38.22 - 'uri': 'file:/root/gentoo.amd64.img', 38.23 + 'location': 'file:/root/gentoo.amd64.img', 38.24 'virtual_size': 0, 38.25 'sector_size': 0, 38.26 'type': 'system', 38.27 @@ -183,13 +178,13 @@ def test_vm_create(): 38.28 execute(server, 'VM.resume', (session, vm_uuid, False)) 38.29 print 'Resumed VM.' 38.30 38.31 + finally: 38.32 # Wait for user to say we're good to shut it down 38.33 while True: 38.34 destroy = raw_input('destroy VM? ') 38.35 if destroy[0] in ('y', 'Y'): 38.36 break 38.37 - 38.38 - finally: 38.39 + 38.40 # Clean up 38.41 if vif_uuid: 38.42 execute(server, 'VIF.destroy', (session, vif_uuid))
39.1 --- a/tools/python/xen/xend/XendAPI.py Sun Feb 04 12:18:48 2007 -0700 39.2 +++ b/tools/python/xen/xend/XendAPI.py Sun Feb 04 12:24:53 2007 -0700 39.3 @@ -22,7 +22,7 @@ import sys 39.4 import traceback 39.5 import threading 39.6 39.7 -from xen.xend import XendDomain, XendDomainInfo, XendNode 39.8 +from xen.xend import XendDomain, XendDomainInfo, XendNode, XendDmesg 39.9 from xen.xend import XendLogging, XendTaskManager 39.10 39.11 from xen.xend.XendAuthSessions import instance as auth_manager 39.12 @@ -615,7 +615,8 @@ class XendAPI(object): 39.13 ('reboot', None), 39.14 ('shutdown', None), 39.15 ('add_to_other_config', None), 39.16 - ('remove_from_other_config', None)] 39.17 + ('remove_from_other_config', None), 39.18 + ('dmesg', 'String')] 39.19 39.20 host_funcs = [('get_by_name_label', 'Set(host)')] 39.21 39.22 @@ -674,6 +675,9 @@ class XendAPI(object): 39.23 return xen_api_error(XEND_ERROR_HOST_RUNNING) 39.24 return xen_api_error(XEND_ERROR_UNSUPPORTED) 39.25 39.26 + def host_dmesg(self, session, host_ref): 39.27 + return xen_api_success(XendDmesg.instance().info()) 39.28 + 39.29 def host_get_record(self, session, host_ref): 39.30 node = XendNode.instance() 39.31 dom = XendDomain.instance() 39.32 @@ -737,7 +741,7 @@ class XendAPI(object): 39.33 'memory_free', 39.34 'host'] 39.35 host_metrics_attr_rw = [] 39.36 - host_methods = [] 39.37 + host_metrics_methods = [] 39.38 39.39 def _host_metrics_get(self, ref, f): 39.40 return xen_api_success(getattr(node, f)()) 39.41 @@ -974,7 +978,8 @@ class XendAPI(object): 39.42 'PV_ramdisk', 39.43 'PV_args', 39.44 'PV_bootloader_args', 39.45 - 'HVM_boot', 39.46 + 'HVM_boot_policy', 39.47 + 'HVM_boot_params', 39.48 'platform_std_VGA', 39.49 'platform_serial', 39.50 'platform_localtime', 39.51 @@ -1020,7 +1025,8 @@ class XendAPI(object): 39.52 'PV_ramdisk', 39.53 'PV_args', 39.54 'PV_bootloader_args', 39.55 - 'HVM_boot', 39.56 + 'HVM_boot_policy', 39.57 + 'HVM_boot_params', 39.58 'platform_std_VGA', 39.59 'platform_serial', 39.60 'platform_localtime', 39.61 @@ -1121,11 +1127,11 @@ class XendAPI(object): 39.62 39.63 def VM_get_VCPUs_policy(self, session, vm_ref): 39.64 dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 39.65 - return dom.get_vcpus_policy() 39.66 + return xen_api_success(dom.get_vcpus_policy()) 39.67 39.68 def VM_get_VCPUs_params(self, session, vm_ref): 39.69 dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 39.70 - return xen_api_todo() # need access to scheduler 39.71 + return xen_api_success(dom.get_vcpus_params()) 39.72 39.73 def VM_get_actions_after_shutdown(self, session, vm_ref): 39.74 dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 39.75 @@ -1158,8 +1164,11 @@ class XendAPI(object): 39.76 def VM_get_PV_bootloader_args(self, session, vm_ref): 39.77 return self.VM_get('PV_bootloader_args', session, vm_ref) 39.78 39.79 - def VM_get_HVM_boot(self, session, vm_ref): 39.80 - return self.VM_get('HVM_boot', session, vm_ref) 39.81 + def VM_get_HVM_boot_policy(self, session, vm_ref): 39.82 + return self.VM_get('HVM_boot_policy', session, vm_ref) 39.83 + 39.84 + def VM_get_HVM_boot_params(self, session, vm_ref): 39.85 + return self.VM_get('HVM_boot_params', session, vm_ref) 39.86 39.87 def VM_get_platform_std_VGA(self, session, vm_ref): 39.88 dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 39.89 @@ -1186,7 +1195,7 @@ class XendAPI(object): 39.90 return xen_api_success(dom.get_platform_keymap()) 39.91 39.92 def VM_get_other_config(self, session, vm_ref): 39.93 - return self.VM_get('otherconfig', session, vm_ref) 39.94 + return self.VM_get('other_config', session, vm_ref) 39.95 39.96 def VM_get_is_control_domain(self, session, vm_ref): 39.97 xd = XendDomain.instance() 39.98 @@ -1246,8 +1255,30 @@ class XendAPI(object): 39.99 return xen_api_error(['VM_ON_CRASH_BEHAVIOUR_INVALID', vm_ref]) 39.100 return self.VM_set('actions_after_crash', session, vm_ref, action) 39.101 39.102 - def VM_set_HVM_boot(self, session, vm_ref, value): 39.103 - return self.VM_set('HVM_boot', session, vm_ref, value) 39.104 + def VM_set_HVM_boot_policy(self, session, vm_ref, value): 39.105 + if value != "" and value != "BIOS order": 39.106 + return xen_api_error( 39.107 + ['VALUE_NOT_SUPPORTED', 'VM.HVM_boot_policy', value, 39.108 + 'Xend supports only the "BIOS order" boot policy.']) 39.109 + else: 39.110 + return self.VM_set('HVM_boot_policy', session, vm_ref, value) 39.111 + 39.112 + def VM_set_HVM_boot_params(self, session, vm_ref, value): 39.113 + return self.VM_set('HVM_boot_params', session, vm_ref, value) 39.114 + 39.115 + def VM_add_to_HVM_boot_params(self, session, vm_ref, key, value): 39.116 + dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 39.117 + if 'HVM_boot_params' not in dom.info: 39.118 + dom.info['HVM_boot_params'] = {} 39.119 + dom.info['HVM_boot_params'][key] = value 39.120 + return xen_api_success_void() 39.121 + 39.122 + def VM_remove_from_HVM_boot_params(self, session, vm_ref, key): 39.123 + dom = XendDomain.instance().get_vm_by_uuid(vm_ref) 39.124 + if 'HVM_boot_params' in dom.info \ 39.125 + and key in dom.info['HVM_boot_params']: 39.126 + del dom.info['HVM_boot_params'][key] 39.127 + return xen_api_success_void() 39.128 39.129 def VM_set_PV_bootloader(self, session, vm_ref, value): 39.130 return self.VM_set('PV_bootloader', session, vm_ref, value) 39.131 @@ -1354,7 +1385,8 @@ class XendAPI(object): 39.132 'PV_ramdisk': xeninfo.info.get('PV_ramdisk'), 39.133 'PV_args': xeninfo.info.get('PV_args'), 39.134 'PV_bootloader_args': xeninfo.info.get('PV_bootloader_args'), 39.135 - 'HVM_boot': xeninfo.info.get('HVM_boot'), 39.136 + 'HVM_boot_policy': xeninfo.info.get('HVM_boot_policy'), 39.137 + 'HVM_boot_params': xeninfo.info.get('HVM_boot_params'), 39.138 'platform_std_VGA': xeninfo.get_platform_std_vga(), 39.139 'platform_serial': xeninfo.get_platform_serial(), 39.140 'platform_localtime': xeninfo.get_platform_localtime(), 39.141 @@ -1363,7 +1395,7 @@ class XendAPI(object): 39.142 'platform_keymap': xeninfo.get_platform_keymap(), 39.143 'PCI_bus': xeninfo.get_pci_bus(), 39.144 'tools_version': xeninfo.get_tools_version(), 39.145 - 'other_config': xeninfo.info.get('otherconfig'), 39.146 + 'other_config': xeninfo.info.get('other_config', {}), 39.147 'is_control_domain': xeninfo == xendom.privilegedDomain(), 39.148 } 39.149 return xen_api_success(record) 39.150 @@ -1469,7 +1501,7 @@ class XendAPI(object): 39.151 vdi = XendNode.instance().get_vdi_by_uuid(vdi_ref) 39.152 if not vdi: 39.153 return xen_api_error(['VDI_HANDLE_INVALID', vdi_ref]) 39.154 - vdi_image = vdi.get_image_uri() 39.155 + vdi_image = vdi.get_location() 39.156 vbd_ref = XendTask.log_progress(0, 100, 39.157 dom.create_vbd, 39.158 vbd_struct, vdi_image) 39.159 @@ -1622,7 +1654,7 @@ class XendAPI(object): 39.160 xendom = XendDomain.instance() 39.161 return xen_api_success(xendom.get_dev_property_by_uuid('vif', vif_ref, 39.162 'io_write_kbs')) 39.163 - 39.164 + 39.165 def VIF_get_all(self, session): 39.166 xendom = XendDomain.instance() 39.167 vifs = [d.get_vifs() for d in XendDomain.instance().list('all')]
40.1 --- a/tools/python/xen/xend/XendAPIConstants.py Sun Feb 04 12:18:48 2007 -0700 40.2 +++ b/tools/python/xen/xend/XendAPIConstants.py Sun Feb 04 12:24:53 2007 -0700 40.3 @@ -12,7 +12,7 @@ 40.4 # License along with this library; if not, write to the Free Software 40.5 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 40.6 #============================================================================ 40.7 -# Copyright (C) 2006 XenSource Ltd. 40.8 +# Copyright (C) 2006-2007 XenSource Ltd. 40.9 #============================================================================ 40.10 40.11 # 40.12 @@ -24,7 +24,7 @@ XEN_API_VM_POWER_STATE = [ 40.13 'Paused', 40.14 'Running', 40.15 'Suspended', 40.16 - 'ShuttingDown', 40.17 + 'Halted', 40.18 'Unknown' 40.19 ] 40.20 40.21 @@ -49,16 +49,8 @@ XEN_API_ON_CRASH_BEHAVIOUR = [ 40.22 'rename_restart' 40.23 ] 40.24 40.25 -XEN_API_BOOT_TYPE = [ 40.26 - 'bios', 40.27 - 'grub', 40.28 - 'kernel_external', 40.29 - 'kernel_internal' 40.30 -] 40.31 - 40.32 XEN_API_VBD_MODE = ['RO', 'RW'] 40.33 XEN_API_VDI_TYPE = ['system', 'user', 'ephemeral'] 40.34 -XEN_API_DRIVER_TYPE = ['ioemu', 'paravirtualised'] 40.35 XEN_API_VBD_TYPE = ['CD', 'Disk'] 40.36 XEN_API_TASK_STATUS_TYPE = ['pending', 'success', 'failure'] 40.37 XEN_API_CONSOLE_PROTOCOL = ['vt100', 'rfb', 'rdp']
41.1 --- a/tools/python/xen/xend/XendBootloader.py Sun Feb 04 12:18:48 2007 -0700 41.2 +++ b/tools/python/xen/xend/XendBootloader.py Sun Feb 04 12:24:53 2007 -0700 41.3 @@ -97,7 +97,9 @@ def bootloader(blexec, disk, dom, quiet 41.4 41.5 try: 41.6 log.debug("Launching bootloader as %s." % str(args)) 41.7 - os.execvp(args[0], args) 41.8 + env = os.environ.copy() 41.9 + env['TERM'] = 'vt100' 41.10 + os.execvpe(args[0], args, env) 41.11 except OSError, e: 41.12 print e 41.13 pass
42.1 --- a/tools/python/xen/xend/XendConfig.py Sun Feb 04 12:18:48 2007 -0700 42.2 +++ b/tools/python/xen/xend/XendConfig.py Sun Feb 04 12:24:53 2007 -0700 42.3 @@ -28,7 +28,7 @@ from xen.xend.PrettyPrint import prettyp 42.4 from xen.xend.XendConstants import DOM_STATE_HALTED 42.5 42.6 log = logging.getLogger("xend.XendConfig") 42.7 -log.setLevel(logging.WARN) 42.8 +log.setLevel(logging.DEBUG) 42.9 42.10 42.11 """ 42.12 @@ -125,8 +125,7 @@ XENAPI_HVM_CFG = { 42.13 'platform_std_vga': 'stdvga', 42.14 'platform_serial' : 'serial', 42.15 'platform_localtime': 'localtime', 42.16 - 'platform_keymap' : 'keymap', 42.17 - 'HVM_boot': 'boot', 42.18 + 'platform_keymap' : 'keymap' 42.19 } 42.20 42.21 # List of XendConfig configuration keys that have no direct equivalent 42.22 @@ -147,24 +146,19 @@ XENAPI_CFG_TYPES = { 42.23 'memory_actual': int, 42.24 'cpus': list, 42.25 'vcpus_policy': str, 42.26 - 'vcpus_params': str, 42.27 + 'vcpus_params': dict, 42.28 'vcpus_number': int, 42.29 - 'vcpus_features_required': list, 42.30 - 'vcpus_features_can_use': list, 42.31 - 'vcpus_features_force_on': list, 42.32 - 'vcpus_features_force_off': list, 42.33 'actions_after_shutdown': str, 42.34 'actions_after_reboot': str, 42.35 - 'actions_after_suspend': str, 42.36 'actions_after_crash': str, 42.37 - 'tpm_instance': int, 42.38 'tpm_backend': int, 42.39 'PV_bootloader': str, 42.40 'PV_kernel': str, 42.41 'PV_ramdisk': str, 42.42 'PV_args': str, 42.43 'PV_bootloader_args': str, 42.44 - 'HVM_boot': str, 42.45 + 'HVM_boot_policy': str, 42.46 + 'HVM_boot_params': dict, 42.47 'platform_std_vga': bool0, 42.48 'platform_serial': str, 42.49 'platform_localtime': bool0, 42.50 @@ -349,7 +343,6 @@ class XendConfig(dict): 42.51 42.52 def _defaults(self): 42.53 defaults = { 42.54 - 'uuid': uuid.createString(), 42.55 'name_label': 'Domain-Unnamed', 42.56 'actions_after_shutdown': 'destroy', 42.57 'actions_after_reboot': 'restart', 42.58 @@ -361,7 +354,8 @@ class XendConfig(dict): 42.59 'PV_ramdisk': '', 42.60 'PV_args': '', 42.61 'PV_bootloader_args': '', 42.62 - 'HVM_boot': '', 42.63 + 'HVM_boot_policy': '', 42.64 + 'HVM_boot_params': {}, 42.65 'memory_static_min': 0, 42.66 'memory_dynamic_min': 0, 42.67 'shadow_memory': 0, 42.68 @@ -377,6 +371,7 @@ class XendConfig(dict): 42.69 'cpu_weight': 256, 42.70 'cpu_cap': 0, 42.71 'vcpus_number': 1, 42.72 + 'vcpus_params': {}, 42.73 'console_refs': [], 42.74 'vif_refs': [], 42.75 'vbd_refs': [], 42.76 @@ -384,7 +379,6 @@ class XendConfig(dict): 42.77 'other_config': {}, 42.78 } 42.79 42.80 - defaults['name_label'] = 'Domain-' + defaults['uuid'] 42.81 return defaults 42.82 42.83 def _memory_sanity_check(self): 42.84 @@ -414,13 +408,21 @@ class XendConfig(dict): 42.85 42.86 def _uuid_sanity_check(self): 42.87 """Make sure UUID is in proper string format with hyphens.""" 42.88 - self['uuid'] = uuid.toString(uuid.fromString(self['uuid'])) 42.89 + if 'uuid' not in self or not self['uuid']: 42.90 + self['uuid'] = uuid.createString() 42.91 + else: 42.92 + self['uuid'] = uuid.toString(uuid.fromString(self['uuid'])) 42.93 + 42.94 + def _name_sanity_check(self): 42.95 + if 'name_label' not in self: 42.96 + self['name_label'] = 'Domain-' + self['uuid'] 42.97 42.98 def validate(self): 42.99 + self._uuid_sanity_check() 42.100 + self._name_sanity_check() 42.101 self._memory_sanity_check() 42.102 self._actions_sanity_check() 42.103 self._vcpus_sanity_check() 42.104 - self._uuid_sanity_check() 42.105 42.106 def _dominfo_to_xapi(self, dominfo): 42.107 self['domid'] = dominfo['domid'] 42.108 @@ -496,6 +498,12 @@ class XendConfig(dict): 42.109 log.warn("Unable to parse key %s: %s: %s" % 42.110 (key, str(val), e)) 42.111 42.112 + # Compatibility hack -- can go soon. 42.113 + boot_order = sxp.child_value(sxp_cfg, 'HVM_boot') 42.114 + if boot_order: 42.115 + cfg['HVM_boot_policy'] = 'BIOS order' 42.116 + cfg['HVM_boot_params'] = { 'order' : boot_order } 42.117 + 42.118 # Parsing the device SXP's. In most cases, the SXP looks 42.119 # like this: 42.120 # 42.121 @@ -671,6 +679,9 @@ class XendConfig(dict): 42.122 if self['devices'][console_uuid][1].get('protocol') == 'rfb': 42.123 has_rfb = True 42.124 break 42.125 + if self['devices'][console_uuid][0] == 'vfb': 42.126 + has_rfb = True 42.127 + break 42.128 42.129 if not has_rfb: 42.130 dev_config = ['vfb'] 42.131 @@ -724,6 +735,7 @@ class XendConfig(dict): 42.132 val = sxp.child_value(image_sxp, imgkey, None) 42.133 if val != None: 42.134 self[apikey] = val 42.135 + self._hvm_boot_params_from_sxp(image_sxp) 42.136 42.137 # extract backend value 42.138 42.139 @@ -768,7 +780,7 @@ class XendConfig(dict): 42.140 if 'image' in xapi_dict: 42.141 self['image'].update(xapi_dict['image']) 42.142 else: 42.143 - hvm = self['HVM_boot'] != '' 42.144 + hvm = self['HVM_boot_policy'] != '' 42.145 self['image']['type'] = hvm and 'hvm' or 'linux' 42.146 if hvm: 42.147 self['image']['hvm'] = {'devices': {}} 42.148 @@ -829,8 +841,6 @@ class XendConfig(dict): 42.149 else: 42.150 self[key] = val 42.151 42.152 - self.validate() 42.153 - 42.154 def to_sxp(self, domain = None, ignore_devices = False, ignore = [], 42.155 legacy_only = True): 42.156 """ Get SXP representation of this config object. 42.157 @@ -854,9 +864,13 @@ class XendConfig(dict): 42.158 sxpr.append(['domid', domain.getDomid()]) 42.159 42.160 if not legacy_only: 42.161 - for name in XENAPI_CFG_TYPES.keys(): 42.162 + for name, typ in XENAPI_CFG_TYPES.items(): 42.163 if name in self and self[name] not in (None, []): 42.164 - sxpr.append([name, str(self[name])]) 42.165 + if typ == dict: 42.166 + s = self[name].items() 42.167 + else: 42.168 + s = str(self[name]) 42.169 + sxpr.append([name, s]) 42.170 42.171 for xenapi, legacy in XENAPI_CFG_TO_LEGACY_CFG.items(): 42.172 if self.has_key(xenapi) and self[xenapi] not in (None, []): 42.173 @@ -905,7 +919,7 @@ class XendConfig(dict): 42.174 # store as part of the device config. 42.175 dev_uuid = sxp.child_value(config, 'uuid') 42.176 dev_type, dev_cfg = self['devices'][dev_uuid] 42.177 - is_bootable = dev_cfg.get('bootable', False) 42.178 + is_bootable = dev_cfg.get('bootable', 0) 42.179 config.append(['bootable', int(is_bootable)]) 42.180 42.181 sxpr.append(['device', config]) 42.182 @@ -978,14 +992,16 @@ class XendConfig(dict): 42.183 pass 42.184 42.185 if dev_type == 'vbd': 42.186 - dev_info['bootable'] = False 42.187 + dev_info['bootable'] = 0 42.188 if dev_info.get('dev', '').startswith('ioemu:'): 42.189 dev_info['driver'] = 'ioemu' 42.190 else: 42.191 dev_info['driver'] = 'paravirtualised' 42.192 42.193 # create uuid if it doesn't exist 42.194 - dev_uuid = dev_info.get('uuid', uuid.createString()) 42.195 + dev_uuid = dev_info.get('uuid', None) 42.196 + if not dev_uuid: 42.197 + dev_uuid = uuid.createString() 42.198 dev_info['uuid'] = dev_uuid 42.199 42.200 # store dev references by uuid for certain device types 42.201 @@ -998,7 +1014,7 @@ class XendConfig(dict): 42.202 if dev_type == 'vbd' and not target[param]: 42.203 # Compat hack -- this is the first disk, so mark it 42.204 # bootable. 42.205 - dev_info['bootable'] = True 42.206 + dev_info['bootable'] = 1 42.207 target[param].append(dev_uuid) 42.208 elif dev_type == 'tap': 42.209 if 'vbd_refs' not in target: 42.210 @@ -1007,7 +1023,7 @@ class XendConfig(dict): 42.211 if not target['vbd_refs']: 42.212 # Compat hack -- this is the first disk, so mark it 42.213 # bootable. 42.214 - dev_info['bootable'] = True 42.215 + dev_info['bootable'] = 1 42.216 target['vbd_refs'].append(dev_uuid) 42.217 42.218 elif dev_type == 'vfb': 42.219 @@ -1055,7 +1071,9 @@ class XendConfig(dict): 42.220 if cfg_xenapi.get('name'): 42.221 dev_info['name'] = cfg_xenapi.get('name') 42.222 42.223 - dev_uuid = cfg_xenapi.get('uuid', uuid.createString()) 42.224 + dev_uuid = cfg_xenapi.get('uuid', None) 42.225 + if not dev_uuid: 42.226 + dev_uuid = uuid.createString() 42.227 dev_info['uuid'] = dev_uuid 42.228 target['devices'][dev_uuid] = (dev_type, dev_info) 42.229 target['vif_refs'].append(dev_uuid) 42.230 @@ -1070,8 +1088,8 @@ class XendConfig(dict): 42.231 dev_info['uname'] = cfg_xenapi.get('image', '') 42.232 dev_info['dev'] = '%s:%s' % (cfg_xenapi.get('device'), 42.233 old_vbd_type) 42.234 - dev_info['bootable'] = cfg_xenapi.get('bootable', False) 42.235 - dev_info['driver'] = cfg_xenapi.get('driver') 42.236 + dev_info['bootable'] = int(cfg_xenapi.get('bootable', 0)) 42.237 + dev_info['driver'] = cfg_xenapi.get('driver', '') 42.238 dev_info['VDI'] = cfg_xenapi.get('VDI', '') 42.239 42.240 if cfg_xenapi.get('mode') == 'RW': 42.241 @@ -1079,7 +1097,9 @@ class XendConfig(dict): 42.242 else: 42.243 dev_info['mode'] = 'r' 42.244 42.245 - dev_uuid = cfg_xenapi.get('uuid', uuid.createString()) 42.246 + dev_uuid = cfg_xenapi.get('uuid', None) 42.247 + if not dev_uuid: 42.248 + dev_uuid = uuid.createString() 42.249 dev_info['uuid'] = dev_uuid 42.250 target['devices'][dev_uuid] = (dev_type, dev_info) 42.251 target['vbd_refs'].append(dev_uuid) 42.252 @@ -1088,13 +1108,17 @@ class XendConfig(dict): 42.253 if cfg_xenapi.get('type'): 42.254 dev_info['type'] = cfg_xenapi.get('type') 42.255 42.256 - dev_uuid = cfg_xenapi.get('uuid', uuid.createString()) 42.257 + dev_uuid = cfg_xenapi.get('uuid', None) 42.258 + if not dev_uuid: 42.259 + dev_uuid = uuid.createString() 42.260 dev_info['uuid'] = dev_uuid 42.261 target['devices'][dev_uuid] = (dev_type, dev_info) 42.262 target['vtpm_refs'].append(dev_uuid) 42.263 42.264 elif dev_type == 'console': 42.265 - dev_uuid = cfg_xenapi.get('uuid', uuid.createString()) 42.266 + dev_uuid = cfg_xenapi.get('uuid', None) 42.267 + if not dev_uuid: 42.268 + dev_uuid = uuid.createString() 42.269 dev_info['uuid'] = dev_uuid 42.270 dev_info['protocol'] = cfg_xenapi.get('protocol', 'rfb') 42.271 dev_info['other_config'] = cfg_xenapi.get('other_config', {}) 42.272 @@ -1223,7 +1247,12 @@ class XendConfig(dict): 42.273 "configuration dictionary.") 42.274 42.275 sxpr.append(dev_type) 42.276 - config = [(opt, val) for opt, val in dev_info.items()] 42.277 + if dev_type in ('console', 'vfb'): 42.278 + config = [(opt, val) for opt, val in dev_info.items() 42.279 + if opt != 'other_config'] 42.280 + else: 42.281 + config = [(opt, val) for opt, val in dev_info.items()] 42.282 + 42.283 sxpr += config 42.284 42.285 return sxpr 42.286 @@ -1356,12 +1385,19 @@ class XendConfig(dict): 42.287 val = sxp.child_value(image_sxp, imgkey, None) 42.288 if val != None: 42.289 type_conv = XENAPI_CFG_TYPES[apikey] 42.290 - if callable(conv): 42.291 + if callable(type_conv): 42.292 self[apikey] = type_conv(val) 42.293 else: 42.294 self[apikey] = val 42.295 + self._hvm_boot_params_from_sxp(image_sxp) 42.296 42.297 42.298 + def _hvm_boot_params_from_sxp(self, image_sxp): 42.299 + boot = sxp.child_value(image_sxp, 'boot', None) 42.300 + if boot is not None: 42.301 + self['HVM_boot_policy'] = 'BIOS order' 42.302 + self['HVM_boot_params'] = { 'order' : boot } 42.303 + 42.304 42.305 # 42.306 # debugging
43.1 --- a/tools/python/xen/xend/XendDomainInfo.py Sun Feb 04 12:18:48 2007 -0700 43.2 +++ b/tools/python/xen/xend/XendDomainInfo.py Sun Feb 04 12:24:53 2007 -0700 43.3 @@ -1648,14 +1648,15 @@ class XendDomainInfo: 43.4 kernel = self.info['PV_kernel'] 43.5 ramdisk = self.info['PV_ramdisk'] 43.6 args = self.info['PV_args'] 43.7 - boot = self.info['HVM_boot'] 43.8 + boot = self.info['HVM_boot_policy'] 43.9 43.10 if boot: 43.11 # HVM booting. 43.12 self.info['image']['type'] = 'hvm' 43.13 if not 'devices' in self.info['image']: 43.14 self.info['image']['devices'] = {} 43.15 - self.info['image']['devices']['boot'] = boot 43.16 + self.info['image']['devices']['boot'] = \ 43.17 + self.info['HVM_boot_params'].get('order', 'dc') 43.18 elif not blexec and kernel: 43.19 # Boot from dom0. Nothing left to do -- the kernel and ramdisk 43.20 # will be picked up by image.py. 43.21 @@ -1976,7 +1977,11 @@ class XendDomainInfo: 43.22 else: 43.23 return 'unknown' 43.24 def get_vcpus_params(self): 43.25 - return '' # TODO 43.26 + if self.getDomid() is None: 43.27 + return self.info['vcpus_params'] 43.28 + 43.29 + retval = xc.sched_credit_domain_get(self.getDomid()) 43.30 + return retval 43.31 def get_power_state(self): 43.32 return XEN_API_VM_POWER_STATE[self.state] 43.33 def get_platform_std_vga(self):
44.1 --- a/tools/python/xen/xend/XendVDI.py Sun Feb 04 12:18:48 2007 -0700 44.2 +++ b/tools/python/xen/xend/XendVDI.py Sun Feb 04 12:24:53 2007 -0700 44.3 @@ -73,6 +73,7 @@ class XendVDI(AutoSaveObject): 44.4 self.sharable = False 44.5 self.read_only = False 44.6 self.type = "system" 44.7 + self.location = '' 44.8 44.9 def load_config_dict(self, cfg): 44.10 """Loads configuration into the object from a dict. 44.11 @@ -147,9 +148,10 @@ class XendVDI(AutoSaveObject): 44.12 'sharable': False, 44.13 'readonly': False, 44.14 'SR': self.sr_uuid, 44.15 + 'location': self.get_location(), 44.16 'VBDs': []} 44.17 44.18 - def get_image_uri(self): 44.19 + def get_location(self): 44.20 raise NotImplementedError() 44.21 44.22 44.23 @@ -163,9 +165,10 @@ class XendQCoWVDI(XendVDI): 44.24 self.virtual_size = vsize 44.25 self.sector_size = 512 44.26 self.auto_save = True 44.27 + self.location = 'tap:qcow:%s' % self.qcow_path 44.28 44.29 - def get_image_uri(self): 44.30 - return 'tap:qcow:%s' % self.qcow_path 44.31 + def get_location(self): 44.32 + return self.location 44.33 44.34 class XendLocalVDI(XendVDI): 44.35 def __init__(self, vdi_struct): 44.36 @@ -183,7 +186,7 @@ class XendLocalVDI(XendVDI): 44.37 self.type = vdi_struct.get('type', '') 44.38 self.sharable = vdi_struct.get('sharable', False) 44.39 self.read_only = vdi_struct.get('read_only', False) 44.40 - self.image_uri = vdi_struct.get('uri', 'file:/dev/null') 44.41 + self.location = vdi_struct.get('location', 'file:/dev/null') 44.42 44.43 - def get_image_uri(self): 44.44 - return self.image_uri 44.45 + def get_location(self): 44.46 + return self.location
45.1 --- a/tools/python/xen/xend/image.py Sun Feb 04 12:18:48 2007 -0700 45.2 +++ b/tools/python/xen/xend/image.py Sun Feb 04 12:24:53 2007 -0700 45.3 @@ -449,48 +449,50 @@ class HVMImageHandler(ImageHandler): 45.4 return ret 45.5 45.6 vnc_config = {} 45.7 - has_vfb = False 45.8 - has_vnc = int(vmConfig['image'].get('vnc')) != 0 45.9 + has_vnc = int(vmConfig['image'].get('vnc', 0)) != 0 45.10 + has_sdl = int(vmConfig['image'].get('sdl', 0)) != 0 45.11 for dev_uuid in vmConfig['console_refs']: 45.12 - dev_type, dev_info = vmConfig['devices'][devuuid] 45.13 - if dev_type == 'rfb': 45.14 + dev_type, dev_info = vmConfig['devices'][dev_uuid] 45.15 + if dev_type == 'vfb': 45.16 vnc_config = dev_info.get('other_config', {}) 45.17 - has_vfb = True 45.18 + has_vnc = True 45.19 break 45.20 45.21 - if not vnc_config: 45.22 - for key in ('vncunused', 'vnclisten', 'vncdisplay', 'vncpasswd'): 45.23 - if key in vmConfig['image']: 45.24 - vnc_config[key] = vmConfig['image'][key] 45.25 + if has_vnc: 45.26 + if not vnc_config: 45.27 + for key in ('vncunused', 'vnclisten', 'vncdisplay', 45.28 + 'vncpasswd'): 45.29 + if key in vmConfig['image']: 45.30 + vnc_config[key] = vmConfig['image'][key] 45.31 45.32 - if not has_vfb and not has_vnc: 45.33 - ret.append('-nographic') 45.34 - return ret 45.35 - 45.36 - 45.37 - if not vnc_config.get('vncunused', 0) and \ 45.38 - vnc_config.get('vncdisplay', 0): 45.39 - ret.append('-vnc') 45.40 - ret.append(str(vncdisplay)) 45.41 - else: 45.42 - ret.append('-vncunused') 45.43 + if not vnc_config.get('vncunused', 0) and \ 45.44 + vnc_config.get('vncdisplay', 0): 45.45 + ret.append('-vnc') 45.46 + ret.append(str(vncdisplay)) 45.47 + else: 45.48 + ret.append('-vncunused') 45.49 45.50 - vnclisten = vnc_config.get('vnclisten', 45.51 - xenopts().get_vnclisten_address()) 45.52 - ret.append('-vnclisten') 45.53 - ret.append(str(vnclisten)) 45.54 - 45.55 - # Store vncpassword in xenstore 45.56 - vncpasswd = vnc_config.get('vncpasswd') 45.57 - if not vncpasswd: 45.58 - vncpasswd = xenopts().get_vncpasswd_default() 45.59 - 45.60 - if vncpasswd is None: 45.61 - raise VmError('vncpasswd is not setup in vmconfig or ' 45.62 - 'xend-config.sxp') 45.63 + vnclisten = vnc_config.get('vnclisten', 45.64 + xenopts().get_vnclisten_address()) 45.65 + ret.append('-vnclisten') 45.66 + ret.append(str(vnclisten)) 45.67 + 45.68 + # Store vncpassword in xenstore 45.69 + vncpasswd = vnc_config.get('vncpasswd') 45.70 + if not vncpasswd: 45.71 + vncpasswd = xenopts().get_vncpasswd_default() 45.72 45.73 - if vncpasswd != '': 45.74 - self.vm.storeVm('vncpasswd', vncpasswd) 45.75 + if vncpasswd is None: 45.76 + raise VmError('vncpasswd is not setup in vmconfig or ' 45.77 + 'xend-config.sxp') 45.78 + 45.79 + if vncpasswd != '': 45.80 + self.vm.storeVm('vncpasswd', vncpasswd) 45.81 + elif has_sdl: 45.82 + # SDL is default in QEMU. 45.83 + pass 45.84 + else: 45.85 + ret.append('-nographic') 45.86 45.87 return ret 45.88
46.1 --- a/tools/python/xen/xend/server/vfbif.py Sun Feb 04 12:18:48 2007 -0700 46.2 +++ b/tools/python/xen/xend/server/vfbif.py Sun Feb 04 12:24:53 2007 -0700 46.3 @@ -46,7 +46,7 @@ class VfbifController(DevController): 46.4 46.5 def createDevice(self, config): 46.6 DevController.createDevice(self, config) 46.7 - if self.vm.info.get('HVM_boot'): 46.8 + if self.vm.info.get('HVM_boot_policy'): 46.9 # is HVM, so qemu-dm will handle the vfb. 46.10 return 46.11 46.12 @@ -90,7 +90,7 @@ class VfbifController(DevController): 46.13 46.14 46.15 def waitForDevice(self, devid): 46.16 - if self.vm.info.get('HVM_boot'): 46.17 + if self.vm.info.get('HVM_boot_policy'): 46.18 log.debug('skip waiting for HVM vfb') 46.19 # is a qemu-dm managed device, don't wait for hotplug for these. 46.20 return 46.21 @@ -110,7 +110,7 @@ class VfbifController(DevController): 46.22 raise VmError('Refusing to reconfigure device vfb:%d' % devid) 46.23 46.24 def destroyDevice(self, devid, force): 46.25 - if self.vm.info.get('HVM_boot'): 46.26 + if self.vm.info.get('HVM_boot_policy'): 46.27 # remove the backend xenstore entries for HVM guests no matter 46.28 # what 46.29 DevController.destroyDevice(self, devid, True) 46.30 @@ -119,7 +119,7 @@ class VfbifController(DevController): 46.31 46.32 46.33 def migrate(self, deviceConfig, network, dst, step, domName): 46.34 - if self.vm.info.get('HVM_boot'): 46.35 + if self.vm.info.get('HVM_boot_policy'): 46.36 return 0 46.37 return DevController.migrate(self, deviceConfig, network, dst, step, 46.38 domName) 46.39 @@ -136,14 +136,14 @@ class VkbdifController(DevController): 46.40 return (devid, back, front) 46.41 46.42 def waitForDevice(self, config): 46.43 - if self.vm.info.get('HVM_boot'): 46.44 + if self.vm.info.get('HVM_boot_policy'): 46.45 # is a qemu-dm managed device, don't wait for hotplug for these. 46.46 return 46.47 46.48 DevController.waitForDevice(self, config) 46.49 46.50 def destroyDevice(self, devid, force): 46.51 - if self.vm.info.get('HVM_boot'): 46.52 + if self.vm.info.get('HVM_boot_policy'): 46.53 # remove the backend xenstore entries for HVM guests no matter 46.54 # what 46.55 DevController.destroyDevice(self, devid, True) 46.56 @@ -151,7 +151,7 @@ class VkbdifController(DevController): 46.57 DevController.destroyDevice(self, devid, force) 46.58 46.59 def migrate(self, deviceConfig, network, dst, step, domName): 46.60 - if self.vm.info.get('HVM_boot'): 46.61 + if self.vm.info.get('HVM_boot_policy'): 46.62 return 0 46.63 return DevController.migrate(self, deviceConfig, network, dst, step, 46.64 domName)
47.1 --- a/tools/python/xen/xm/messages/en/xen-xm.po Sun Feb 04 12:18:48 2007 -0700 47.2 +++ b/tools/python/xen/xm/messages/en/xen-xm.po Sun Feb 04 12:24:53 2007 -0700 47.3 @@ -19,7 +19,7 @@ 47.4 msgid "" 47.5 msgstr "" 47.6 "Project-Id-Version: Xen-xm 3.0\n" 47.7 -"PO-Revision-Date: 2007-01-30 17:15+0000\n" 47.8 +"PO-Revision-Date: 2007-01-31 12:34+0000\n" 47.9 "Last-Translator: Ewan Mellor <ewan@xensource.com>\n" 47.10 "Language-Team: xen-devel <xen-devel@lists.xensource.com>\n" 47.11 "MIME-Version: 1.0\n" 47.12 @@ -41,6 +41,9 @@ msgstr "The method %(1)s takes %(2)s arg 47.13 msgid "SESSION_AUTHENTICATION_FAILED" 47.14 msgstr "Permission denied." 47.15 47.16 +msgid "VALUE_NOT_SUPPORTED" 47.17 +msgstr "Value \"%(2)s\" for %(1)s is not supported by this server. The server said \"%(3)s\"." 47.18 + 47.19 msgid "HOST_CPU_HANDLE_INVALID" 47.20 msgstr "The host_cpu handle %(1)s is invalid." 47.21
48.1 --- a/tools/xcutils/readnotes.c Sun Feb 04 12:18:48 2007 -0700 48.2 +++ b/tools/xcutils/readnotes.c Sun Feb 04 12:24:53 2007 -0700 48.3 @@ -72,8 +72,8 @@ int main(int argc, char **argv) 48.4 usize = xc_dom_check_gzip(image, st.st_size); 48.5 if (usize) 48.6 { 48.7 - tmp = malloc(size); 48.8 - xc_dom_do_gunzip(image, st.st_size, tmp, size); 48.9 + tmp = malloc(usize); 48.10 + xc_dom_do_gunzip(image, st.st_size, tmp, usize); 48.11 image = tmp; 48.12 size = usize; 48.13 }
49.1 --- a/tools/xm-test/configure.ac Sun Feb 04 12:18:48 2007 -0700 49.2 +++ b/tools/xm-test/configure.ac Sun Feb 04 12:24:53 2007 -0700 49.3 @@ -11,10 +11,12 @@ AC_PROG_CC 49.4 #AC_PROG_INSTALL 49.5 AC_CHECK_PROG([LILO], lilo, lilo, "no", [$PATH]) 49.6 49.7 +XEN_PYTHON_PATH=$(/usr/sbin/xen-python-path) 49.8 + 49.9 # Right now, we can assume that the lib/ directory 49.10 # is two levels above the tests 49.11 TESTLIB=../../lib 49.12 -TENV="PYTHONPATH=$PYTHONPATH:$TESTLIB" 49.13 +TENV="PYTHONPATH=$PYTHONPATH:$TESTLIB:$XEN_PYTHON_PATH" 49.14 49.15 AC_ARG_ENABLE(hvm-support, 49.16 [[ --enable-hvm-support enable hardware virtual machine assist]],
50.1 --- a/tools/xm-test/lib/XmTestLib/XenDomain.py Sun Feb 04 12:18:48 2007 -0700 50.2 +++ b/tools/xm-test/lib/XmTestLib/XenDomain.py Sun Feb 04 12:24:53 2007 -0700 50.3 @@ -33,6 +33,9 @@ from DomainTracking import * 50.4 from acm import * 50.5 50.6 50.7 +DOM0_UUID = "00000000-0000-0000-0000-000000000000" 50.8 + 50.9 + 50.10 def getDefaultKernel(): 50.11 return arch.getDefaultKernel() 50.12
51.1 --- a/tools/xm-test/lib/XmTestLib/__init__.py Sun Feb 04 12:18:48 2007 -0700 51.2 +++ b/tools/xm-test/lib/XmTestLib/__init__.py Sun Feb 04 12:24:53 2007 -0700 51.3 @@ -3,26 +3,6 @@ 51.4 # Author: Dan Smith <danms@us.ibm.com> 51.5 # 51.6 51.7 -import os.path 51.8 -import sys 51.9 - 51.10 -# Use the auxbin module in Xend to determine the correct Python path. We 51.11 -# take the first installed instance of auxbin that we find, and then run it 51.12 -# to determine the correct path, appending that to sys.path. 51.13 - 51.14 -AUXBIN = 'xen/util/auxbin.py' 51.15 - 51.16 -for p in ['python%s' % sys.version[:3], 'python']: 51.17 - for l in ['/usr/lib64', '/usr/lib']: 51.18 - d = os.path.join(l, p) 51.19 - if os.path.exists(os.path.join(d, AUXBIN)): 51.20 - sys.path.append(d) 51.21 - import xen.util.auxbin 51.22 - libpath = xen.util.auxbin.libpath() 51.23 - sys.path = sys.path[:-1] 51.24 - sys.path.append(libpath) 51.25 - break 51.26 - 51.27 from Console import * 51.28 from Test import * 51.29 from Xm import *
52.1 --- a/tools/xm-test/tests/vtpm/09_vtpm-xapi.py Sun Feb 04 12:18:48 2007 -0700 52.2 +++ b/tools/xm-test/tests/vtpm/09_vtpm-xapi.py Sun Feb 04 12:24:53 2007 -0700 52.3 @@ -13,7 +13,6 @@ 52.4 from XmTestLib import xapi 52.5 from XmTestLib.XenAPIDomain import XmTestAPIDomain 52.6 from XmTestLib import * 52.7 -from xen.xend import XendDomain 52.8 from vtpm_utils import * 52.9 import commands 52.10 import os 52.11 @@ -28,7 +27,7 @@ except Exception, e: 52.12 vm_uuid = domain.get_uuid() 52.13 52.14 vtpmcfg = {} 52.15 -vtpmcfg['backend'] = XendDomain.DOM0_UUID 52.16 +vtpmcfg['backend'] = DOM0_UUID 52.17 vtpmcfg['VM'] = vm_uuid 52.18 52.19 session = xapi.connect()
53.1 --- a/xen/arch/x86/dmi_scan.c Sun Feb 04 12:18:48 2007 -0700 53.2 +++ b/xen/arch/x86/dmi_scan.c Sun Feb 04 12:24:53 2007 -0700 53.3 @@ -159,7 +159,7 @@ static void __init dmi_save_ident(struct 53.4 return; 53.5 dmi_ident[slot] = alloc_bootmem(strlen(p)+1); 53.6 if(dmi_ident[slot]) 53.7 - safe_strcpy(dmi_ident[slot], p); 53.8 + strlcpy(dmi_ident[slot], p, strlen(p)+1); 53.9 else 53.10 printk(KERN_ERR "dmi_save_ident: out of memory.\n"); 53.11 }
54.1 --- a/xen/arch/x86/domctl.c Sun Feb 04 12:18:48 2007 -0700 54.2 +++ b/xen/arch/x86/domctl.c Sun Feb 04 12:24:53 2007 -0700 54.3 @@ -288,71 +288,73 @@ long arch_do_domctl( 54.4 54.5 case XEN_DOMCTL_sethvmcontext: 54.6 { 54.7 - struct hvm_domain_context *c; 54.8 + struct hvm_domain_context c; 54.9 struct domain *d; 54.10 54.11 + c.cur = 0; 54.12 + c.size = domctl->u.hvmcontext.size; 54.13 + c.data = NULL; 54.14 + 54.15 ret = -ESRCH; 54.16 if ( (d = get_domain_by_id(domctl->domain)) == NULL ) 54.17 break; 54.18 54.19 - ret = -ENOMEM; 54.20 - if ( (c = xmalloc(struct hvm_domain_context)) == NULL ) 54.21 - goto sethvmcontext_out; 54.22 - 54.23 - ret = -EFAULT; 54.24 - if ( copy_from_guest(c, domctl->u.hvmcontext.ctxt, 1) != 0 ) 54.25 - goto sethvmcontext_out; 54.26 - c->size = sizeof (c->data); 54.27 - c->cur = 0; 54.28 - 54.29 ret = -EINVAL; 54.30 if ( !is_hvm_domain(d) ) 54.31 goto sethvmcontext_out; 54.32 54.33 - ret = hvm_load(d, c); 54.34 + ret = -ENOMEM; 54.35 + if ( (c.data = xmalloc_bytes(c.size)) == NULL ) 54.36 + goto sethvmcontext_out; 54.37 54.38 - xfree(c); 54.39 + ret = -EFAULT; 54.40 + if ( copy_from_guest(c.data, domctl->u.hvmcontext.buffer, c.size) != 0) 54.41 + goto sethvmcontext_out; 54.42 + 54.43 + ret = hvm_load(d, &c); 54.44 54.45 sethvmcontext_out: 54.46 + if ( c.data != NULL ) 54.47 + xfree(c.data); 54.48 + 54.49 put_domain(d); 54.50 - 54.51 } 54.52 break; 54.53 54.54 case XEN_DOMCTL_gethvmcontext: 54.55 { 54.56 - struct hvm_domain_context *c; 54.57 + struct hvm_domain_context c; 54.58 struct domain *d; 54.59 54.60 + c.cur = 0; 54.61 + c.size = domctl->u.hvmcontext.size; 54.62 + c.data = NULL; 54.63 + 54.64 ret = -ESRCH; 54.65 if ( (d = get_domain_by_id(domctl->domain)) == NULL ) 54.66 break; 54.67 54.68 - ret = -ENOMEM; 54.69 - if ( (c = xmalloc(struct hvm_domain_context)) == NULL ) 54.70 - goto gethvmcontext_out; 54.71 - memset(c, 0, sizeof(*c)); 54.72 - c->size = sizeof (c->data); 54.73 - 54.74 - ret = -ENODATA; 54.75 + ret = -EINVAL; 54.76 if ( !is_hvm_domain(d) ) 54.77 goto gethvmcontext_out; 54.78 - 54.79 - ret = 0; 54.80 - if (hvm_save(d, c) != 0) 54.81 - ret = -EFAULT; 54.82 + 54.83 + ret = -ENOMEM; 54.84 + if ( (c.data = xmalloc_bytes(c.size)) == NULL ) 54.85 + goto gethvmcontext_out; 54.86 54.87 - if ( copy_to_guest(domctl->u.hvmcontext.ctxt, c, 1) ) 54.88 + ret = hvm_save(d, &c); 54.89 + 54.90 + if ( copy_to_guest(domctl->u.hvmcontext.buffer, c.data, c.size) != 0 ) 54.91 ret = -EFAULT; 54.92 54.93 - xfree(c); 54.94 - 54.95 if ( copy_to_guest(u_domctl, domctl, 1) ) 54.96 ret = -EFAULT; 54.97 54.98 gethvmcontext_out: 54.99 + if ( c.data != NULL ) 54.100 + xfree(c.data); 54.101 + 54.102 put_domain(d); 54.103 - 54.104 } 54.105 break; 54.106
55.1 --- a/xen/arch/x86/hvm/hpet.c Sun Feb 04 12:18:48 2007 -0700 55.2 +++ b/xen/arch/x86/hvm/hpet.c Sun Feb 04 12:24:53 2007 -0700 55.3 @@ -279,7 +279,7 @@ static void hpet_write( 55.4 (h->hpet.timers[tn].config & HPET_TN_SETVAL) ) 55.5 h->hpet.timers[tn].cmp = new_val; 55.6 else 55.7 - h->period[tn] = new_val; 55.8 + h->hpet.period[tn] = new_val; 55.9 h->hpet.timers[tn].config &= ~HPET_TN_SETVAL; 55.10 if ( hpet_enabled(h) && timer_enabled(h, tn) ) 55.11 hpet_set_timer(h, tn); 55.12 @@ -289,7 +289,7 @@ static void hpet_write( 55.13 case HPET_T1_ROUTE: 55.14 case HPET_T2_ROUTE: 55.15 tn = (addr - HPET_T0_ROUTE) >> 5; 55.16 - h->hpet.timers[tn].hpet_fsb[0] = new_val; 55.17 + h->hpet.timers[tn].fsb = new_val; 55.18 break; 55.19 55.20 default: 55.21 @@ -351,21 +351,22 @@ static void hpet_timer_fn(void *opaque) 55.22 55.23 hpet_route_interrupt(h, tn); 55.24 55.25 - if ( timer_is_periodic(h, tn) && (h->period[tn] != 0) ) 55.26 + if ( timer_is_periodic(h, tn) && (h->hpet.period[tn] != 0) ) 55.27 { 55.28 uint64_t mc = hpet_read_maincounter(h); 55.29 if ( timer_is_32bit(h, tn) ) 55.30 { 55.31 while ( hpet_time_after(mc, h->hpet.timers[tn].cmp) ) 55.32 h->hpet.timers[tn].cmp = (uint32_t)( 55.33 - h->hpet.timers[tn].cmp + h->period[tn]); 55.34 + h->hpet.timers[tn].cmp + h->hpet.period[tn]); 55.35 } 55.36 else 55.37 { 55.38 while ( hpet_time_after64(mc, h->hpet.timers[tn].cmp) ) 55.39 - h->hpet.timers[tn].cmp += h->period[tn]; 55.40 + h->hpet.timers[tn].cmp += h->hpet.period[tn]; 55.41 } 55.42 - set_timer(&h->timers[tn], NOW() + hpet_tick_to_ns(h, h->period[tn])); 55.43 + set_timer(&h->timers[tn], 55.44 + NOW() + hpet_tick_to_ns(h, h->hpet.period[tn])); 55.45 } 55.46 } 55.47 55.48 @@ -378,6 +379,35 @@ void hpet_migrate_timers(struct vcpu *v) 55.49 migrate_timer(&h->timers[i], v->processor); 55.50 } 55.51 55.52 +static int hpet_save(struct domain *d, hvm_domain_context_t *h) 55.53 +{ 55.54 + HPETState *hp = &d->arch.hvm_domain.pl_time.vhpet; 55.55 + 55.56 + /* Save the HPET registers */ 55.57 + return hvm_save_entry(HPET, 0, h, &hp->hpet); 55.58 +} 55.59 + 55.60 +static int hpet_load(struct domain *d, hvm_domain_context_t *h) 55.61 +{ 55.62 + HPETState *hp = &d->arch.hvm_domain.pl_time.vhpet; 55.63 + int i; 55.64 + 55.65 + /* Reload the HPET registers */ 55.66 + if ( hvm_load_entry(HPET, h, &hp->hpet) ) 55.67 + return -EINVAL; 55.68 + 55.69 + /* Recalculate the offset between the main counter and guest time */ 55.70 + hp->mc_offset = hp->hpet.mc64 - hvm_get_guest_time(hp->vcpu); 55.71 + 55.72 + /* Restart the timers */ 55.73 + for ( i = 0; i < HPET_TIMER_NUM; i++ ) 55.74 + hpet_set_timer(hp, i); 55.75 + 55.76 + return 0; 55.77 +} 55.78 + 55.79 +HVM_REGISTER_SAVE_RESTORE(HPET, hpet_save, hpet_load); 55.80 + 55.81 void hpet_init(struct vcpu *v) 55.82 { 55.83 HPETState *h = &v->domain->arch.hvm_domain.pl_time.vhpet;
56.1 --- a/xen/arch/x86/hvm/intercept.c Sun Feb 04 12:18:48 2007 -0700 56.2 +++ b/xen/arch/x86/hvm/intercept.c Sun Feb 04 12:24:53 2007 -0700 56.3 @@ -205,7 +205,7 @@ int hvm_save(struct domain *d, hvm_domai 56.4 if ( hvm_save_entry(HEADER, 0, h, &hdr) != 0 ) 56.5 { 56.6 gdprintk(XENLOG_ERR, "HVM save: failed to write header\n"); 56.7 - return -1; 56.8 + return -EFAULT; 56.9 } 56.10 56.11 /* Save all available kinds of state */ 56.12 @@ -219,7 +219,7 @@ int hvm_save(struct domain *d, hvm_domai 56.13 { 56.14 gdprintk(XENLOG_ERR, 56.15 "HVM save: failed to save type %"PRIu16"\n", i); 56.16 - return -1; 56.17 + return -EFAULT; 56.18 } 56.19 } 56.20 } 56.21 @@ -229,7 +229,7 @@ int hvm_save(struct domain *d, hvm_domai 56.22 { 56.23 /* Run out of data */ 56.24 gdprintk(XENLOG_ERR, "HVM save: no room for end marker.\n"); 56.25 - return -1; 56.26 + return -EFAULT; 56.27 } 56.28 56.29 /* Save macros should not have let us overrun */
57.1 --- a/xen/arch/x86/hvm/svm/svm.c Sun Feb 04 12:18:48 2007 -0700 57.2 +++ b/xen/arch/x86/hvm/svm/svm.c Sun Feb 04 12:24:53 2007 -0700 57.3 @@ -660,6 +660,13 @@ void svm_update_guest_cr3(struct vcpu *v 57.4 v->arch.hvm_svm.vmcb->cr3 = v->arch.hvm_vcpu.hw_cr3; 57.5 } 57.6 57.7 +static void svm_update_vtpr(struct vcpu *v, unsigned long value) 57.8 +{ 57.9 + struct vmcb_struct *vmcb = v->arch.hvm_svm.vmcb; 57.10 + 57.11 + vmcb->vintr.fields.tpr = value & 0x0f; 57.12 +} 57.13 + 57.14 unsigned long svm_get_ctrl_reg(struct vcpu *v, unsigned int num) 57.15 { 57.16 switch ( num ) 57.17 @@ -1048,6 +1055,8 @@ int start_svm(void) 57.18 hvm_funcs.update_host_cr3 = svm_update_host_cr3; 57.19 hvm_funcs.update_guest_cr3 = svm_update_guest_cr3; 57.20 57.21 + hvm_funcs.update_vtpr = svm_update_vtpr; 57.22 + 57.23 hvm_funcs.stts = svm_stts; 57.24 hvm_funcs.set_tsc_offset = svm_set_tsc_offset; 57.25 57.26 @@ -1939,6 +1948,7 @@ static int mov_to_cr(int gpreg, int cr, 57.27 57.28 case 8: 57.29 vlapic_set_reg(vlapic, APIC_TASKPRI, ((value & 0x0F) << 4)); 57.30 + vmcb->vintr.fields.tpr = value & 0x0F; 57.31 break; 57.32 57.33 default:
58.1 --- a/xen/arch/x86/hvm/vlapic.c Sun Feb 04 12:18:48 2007 -0700 58.2 +++ b/xen/arch/x86/hvm/vlapic.c Sun Feb 04 12:24:53 2007 -0700 58.3 @@ -593,6 +593,7 @@ static void vlapic_write(struct vcpu *v, 58.4 { 58.5 case APIC_TASKPRI: 58.6 vlapic_set_reg(vlapic, APIC_TASKPRI, val & 0xff); 58.7 + hvm_update_vtpr(v, (val >> 4) & 0x0f); 58.8 break; 58.9 58.10 case APIC_EOI:
59.1 --- a/xen/arch/x86/hvm/vmx/vmx.c Sun Feb 04 12:18:48 2007 -0700 59.2 +++ b/xen/arch/x86/hvm/vmx/vmx.c Sun Feb 04 12:24:53 2007 -0700 59.3 @@ -986,6 +986,11 @@ static void vmx_inject_exception( 59.4 v->arch.hvm_vmx.cpu_cr2 = cr2; 59.5 } 59.6 59.7 +static void vmx_update_vtpr(struct vcpu *v, unsigned long value) 59.8 +{ 59.9 + /* VMX doesn't have a V_TPR field */ 59.10 +} 59.11 + 59.12 /* Setup HVM interfaces */ 59.13 static void vmx_setup_hvm_funcs(void) 59.14 { 59.15 @@ -1011,6 +1016,8 @@ static void vmx_setup_hvm_funcs(void) 59.16 hvm_funcs.update_host_cr3 = vmx_update_host_cr3; 59.17 hvm_funcs.update_guest_cr3 = vmx_update_guest_cr3; 59.18 59.19 + hvm_funcs.update_vtpr = vmx_update_vtpr; 59.20 + 59.21 hvm_funcs.stts = vmx_stts; 59.22 hvm_funcs.set_tsc_offset = vmx_set_tsc_offset; 59.23
60.1 --- a/xen/arch/x86/traps.c Sun Feb 04 12:18:48 2007 -0700 60.2 +++ b/xen/arch/x86/traps.c Sun Feb 04 12:24:53 2007 -0700 60.3 @@ -597,6 +597,11 @@ static int emulate_forced_invalid_op(str 60.4 if ( !IS_PRIV(current->domain) ) 60.5 clear_bit(X86_FEATURE_MTRR, &d); 60.6 } 60.7 + else if ( regs->eax == 0x80000001 ) 60.8 + { 60.9 + /* Modify Feature Information. */ 60.10 + clear_bit(X86_FEATURE_RDTSCP % 32, &d); 60.11 + } 60.12 else 60.13 { 60.14 (void)cpuid_hypervisor_leaves(regs->eax, &a, &b, &c, &d);
61.1 --- a/xen/arch/x86/x86_64/compat/entry.S Sun Feb 04 12:18:48 2007 -0700 61.2 +++ b/xen/arch/x86/x86_64/compat/entry.S Sun Feb 04 12:24:53 2007 -0700 61.3 @@ -281,9 +281,6 @@ CFIX14: 61.4 .quad CFLT14,CFIX14 61.5 .previous 61.6 61.7 -compat_domctl: 61.8 -compat_sysctl: 61.9 - 61.10 .section .rodata, "a", @progbits 61.11 61.12 ENTRY(compat_hypercall_table) 61.13 @@ -365,8 +362,8 @@ ENTRY(compat_hypercall_args_table) 61.14 .byte 2 /* compat_event_channel_op */ 61.15 .byte 2 /* compat_physdev_op */ 61.16 .byte 2 /* do_hvm_op */ 61.17 - .byte 1 /* compat_sysctl */ /* 35 */ 61.18 - .byte 1 /* compat_domctl */ 61.19 + .byte 1 /* do_sysctl */ /* 35 */ 61.20 + .byte 1 /* do_domctl */ 61.21 .byte 2 /* compat_kexec_op */ 61.22 .rept NR_hypercalls-(.-compat_hypercall_args_table) 61.23 .byte 0 /* compat_ni_hypercall */
62.1 --- a/xen/common/kexec.c Sun Feb 04 12:18:48 2007 -0700 62.2 +++ b/xen/common/kexec.c Sun Feb 04 12:24:53 2007 -0700 62.3 @@ -131,12 +131,20 @@ static __init int register_crashdump_tri 62.4 62.5 static void setup_note(Elf_Note *n, const char *name, int type, int descsz) 62.6 { 62.7 - safe_strcpy(ELFNOTE_NAME(n), name); 62.8 - n->namesz = strlen(name); 62.9 + int l = strlen(name) + 1; 62.10 + strlcpy(ELFNOTE_NAME(n), name, l); 62.11 + n->namesz = l; 62.12 n->descsz = descsz; 62.13 n->type = type; 62.14 } 62.15 62.16 +static int sizeof_note(const char *name, int descsz) 62.17 +{ 62.18 + return (sizeof(Elf_Note) + 62.19 + ELFNOTE_ALIGN(strlen(name)+1) + 62.20 + ELFNOTE_ALIGN(descsz)); 62.21 +} 62.22 + 62.23 #define kexec_get(x) kexec_get_##x 62.24 62.25 #endif 62.26 @@ -155,23 +163,24 @@ static int kexec_get(reserve)(xen_kexec_ 62.27 static int kexec_get(xen)(xen_kexec_range_t *range) 62.28 { 62.29 range->start = virt_to_maddr(_start); 62.30 - range->size = (unsigned long)_end - (unsigned long)_start; 62.31 + range->size = (unsigned long)xenheap_phys_end - (unsigned long)range->start; 62.32 return 0; 62.33 } 62.34 62.35 static int kexec_get(cpu)(xen_kexec_range_t *range) 62.36 { 62.37 int nr = range->nr; 62.38 - int nr_bytes = sizeof(Elf_Note) * 2 62.39 - + ELFNOTE_ALIGN(sizeof(ELF_Prstatus)) 62.40 - + ELFNOTE_ALIGN(sizeof(crash_xen_core_t)); 62.41 + int nr_bytes = 0; 62.42 62.43 if ( nr < 0 || nr >= num_present_cpus() ) 62.44 return -EINVAL; 62.45 62.46 + nr_bytes += sizeof_note("CORE", sizeof(ELF_Prstatus)); 62.47 + nr_bytes += sizeof_note("Xen", sizeof(crash_xen_core_t)); 62.48 + 62.49 /* The Xen info note is included in CPU0's range. */ 62.50 if ( nr == 0 ) 62.51 - nr_bytes += sizeof(Elf_Note) + ELFNOTE_ALIGN(sizeof(crash_xen_info_t)); 62.52 + nr_bytes += sizeof_note("Xen", sizeof(crash_xen_info_t)); 62.53 62.54 if ( per_cpu(crash_notes, nr) == NULL ) 62.55 {
63.1 --- a/xen/common/perfc.c Sun Feb 04 12:18:48 2007 -0700 63.2 +++ b/xen/common/perfc.c Sun Feb 04 12:24:53 2007 -0700 63.3 @@ -136,8 +136,8 @@ static xen_sysctl_perfc_desc_t perfc_d[N 63.4 static xen_sysctl_perfc_val_t *perfc_vals; 63.5 static int perfc_nbr_vals; 63.6 static int perfc_init = 0; 63.7 -static int perfc_copy_info(XEN_GUEST_HANDLE_64(xen_sysctl_perfc_desc_t) desc, 63.8 - XEN_GUEST_HANDLE_64(xen_sysctl_perfc_val_t) val) 63.9 +static int perfc_copy_info(XEN_GUEST_HANDLE(xen_sysctl_perfc_desc_t) desc, 63.10 + XEN_GUEST_HANDLE(xen_sysctl_perfc_val_t) val) 63.11 { 63.12 unsigned int i, j; 63.13 unsigned int v = 0; 63.14 @@ -217,20 +217,29 @@ static int perfc_copy_info(XEN_GUEST_HAN 63.15 int perfc_control(xen_sysctl_perfc_op_t *pc) 63.16 { 63.17 static DEFINE_SPINLOCK(lock); 63.18 + XEN_GUEST_HANDLE(xen_sysctl_perfc_desc_t) desc; 63.19 + XEN_GUEST_HANDLE(xen_sysctl_perfc_val_t) val; 63.20 int rc; 63.21 63.22 + /* 63.23 + * 64 bit guest handles cannot be passed as parameters to 63.24 + * functions so cast to a regular guest handle. 63.25 + */ 63.26 + desc = guest_handle_cast(pc->desc, xen_sysctl_perfc_desc_t); 63.27 + val = guest_handle_cast(pc->val, xen_sysctl_perfc_val_t); 63.28 + 63.29 spin_lock(&lock); 63.30 63.31 switch ( pc->cmd ) 63.32 { 63.33 case XEN_SYSCTL_PERFCOP_reset: 63.34 - perfc_copy_info(pc->desc, pc->val); 63.35 + perfc_copy_info(desc, val); 63.36 perfc_reset(0); 63.37 rc = 0; 63.38 break; 63.39 63.40 case XEN_SYSCTL_PERFCOP_query: 63.41 - perfc_copy_info(pc->desc, pc->val); 63.42 + perfc_copy_info(desc, val); 63.43 rc = 0; 63.44 break; 63.45
64.1 --- a/xen/include/asm-x86/cpufeature.h Sun Feb 04 12:18:48 2007 -0700 64.2 +++ b/xen/include/asm-x86/cpufeature.h Sun Feb 04 12:24:53 2007 -0700 64.3 @@ -49,6 +49,7 @@ 64.4 #define X86_FEATURE_MP (1*32+19) /* MP Capable. */ 64.5 #define X86_FEATURE_NX (1*32+20) /* Execute Disable */ 64.6 #define X86_FEATURE_MMXEXT (1*32+22) /* AMD MMX extensions */ 64.7 +#define X86_FEATURE_RDTSCP (1*32+27) /* RDTSCP */ 64.8 #define X86_FEATURE_LM (1*32+29) /* Long Mode (x86-64) */ 64.9 #define X86_FEATURE_3DNOWEXT (1*32+30) /* AMD 3DNow! extensions */ 64.10 #define X86_FEATURE_3DNOW (1*32+31) /* 3DNow! */
65.1 --- a/xen/include/asm-x86/hvm/domain.h Sun Feb 04 12:18:48 2007 -0700 65.2 +++ b/xen/include/asm-x86/hvm/domain.h Sun Feb 04 12:24:53 2007 -0700 65.3 @@ -49,8 +49,6 @@ struct hvm_domain { 65.4 spinlock_t pbuf_lock; 65.5 65.6 uint64_t params[HVM_NR_PARAMS]; 65.7 - 65.8 - struct hvm_domain_context *hvm_ctxt; 65.9 }; 65.10 65.11 #endif /* __ASM_X86_HVM_DOMAIN_H__ */
66.1 --- a/xen/include/asm-x86/hvm/hvm.h Sun Feb 04 12:18:48 2007 -0700 66.2 +++ b/xen/include/asm-x86/hvm/hvm.h Sun Feb 04 12:24:53 2007 -0700 66.3 @@ -115,6 +115,11 @@ struct hvm_function_table { 66.4 void (*update_guest_cr3)(struct vcpu *v); 66.5 66.6 /* 66.7 + * Reflect the virtual APIC's value in the guest's V_TPR register 66.8 + */ 66.9 + void (*update_vtpr)(struct vcpu *v, unsigned long value); 66.10 + 66.11 + /* 66.12 * Update specifics of the guest state: 66.13 * 1) TS bit in guest cr0 66.14 * 2) TSC offset in guest 66.15 @@ -203,6 +208,12 @@ hvm_update_host_cr3(struct vcpu *v) 66.16 hvm_funcs.update_host_cr3(v); 66.17 } 66.18 66.19 +static inline void 66.20 +hvm_update_vtpr(struct vcpu *v, unsigned long value) 66.21 +{ 66.22 + hvm_funcs.update_vtpr(v, value); 66.23 +} 66.24 + 66.25 void hvm_update_guest_cr3(struct vcpu *v, unsigned long guest_cr3); 66.26 66.27 void hvm_hypercall_page_initialise(struct domain *d,
67.1 --- a/xen/include/asm-x86/hvm/support.h Sun Feb 04 12:18:48 2007 -0700 67.2 +++ b/xen/include/asm-x86/hvm/support.h Sun Feb 04 12:24:53 2007 -0700 67.3 @@ -123,6 +123,13 @@ extern unsigned int opt_hvm_debug_level; 67.4 * Save/restore support 67.5 */ 67.6 67.7 +/* Marshalling and unmarshalling uses a buffer with size and cursor. */ 67.8 +typedef struct hvm_domain_context { 67.9 + uint32_t cur; 67.10 + uint32_t size; 67.11 + uint8_t *data; 67.12 +} hvm_domain_context_t; 67.13 + 67.14 /* Marshalling an entry: check space and fill in the header */ 67.15 static inline int _hvm_init_entry(struct hvm_domain_context *h, 67.16 uint16_t tc, uint16_t inst, uint32_t len)
68.1 --- a/xen/include/asm-x86/hvm/vpt.h Sun Feb 04 12:18:48 2007 -0700 68.2 +++ b/xen/include/asm-x86/hvm/vpt.h Sun Feb 04 12:24:53 2007 -0700 68.3 @@ -31,22 +31,6 @@ 68.4 #include <asm/hvm/vpic.h> 68.5 #include <public/hvm/save.h> 68.6 68.7 -#define HPET_TIMER_NUM 3 /* 3 timers supported now */ 68.8 -struct HPET { 68.9 - uint64_t capability; /* capabilities */ 68.10 - uint64_t res0; /* reserved */ 68.11 - uint64_t config; /* configuration */ 68.12 - uint64_t res1; /* reserved */ 68.13 - uint64_t isr; /* interrupt status reg */ 68.14 - uint64_t res2[25]; /* reserved */ 68.15 - uint64_t mc64; /* main counter */ 68.16 - uint64_t res3; /* reserved */ 68.17 - struct { /* timers */ 68.18 - uint64_t config; /* configuration/cap */ 68.19 - uint64_t cmp; /* comparator */ 68.20 - uint64_t hpet_fsb[2]; /* FSB route, not supported now */ 68.21 - } timers[HPET_TIMER_NUM]; 68.22 -}; 68.23 68.24 struct HPETState; 68.25 struct HPET_timer_fn_info { 68.26 @@ -55,11 +39,10 @@ struct HPET_timer_fn_info { 68.27 }; 68.28 68.29 typedef struct HPETState { 68.30 - struct HPET hpet; 68.31 - struct vcpu *vcpu; 68.32 - uint64_t tsc_freq; 68.33 - uint64_t mc_offset; 68.34 - uint64_t period[HPET_TIMER_NUM]; 68.35 + struct hvm_hw_hpet hpet; 68.36 + struct vcpu *vcpu; 68.37 + uint64_t tsc_freq; 68.38 + uint64_t mc_offset; 68.39 struct timer timers[HPET_TIMER_NUM]; 68.40 struct HPET_timer_fn_info timer_fn_info[HPET_TIMER_NUM]; 68.41 } HPETState;
69.1 --- a/xen/include/public/arch-x86/xen-x86_32.h Sun Feb 04 12:18:48 2007 -0700 69.2 +++ b/xen/include/public/arch-x86/xen-x86_32.h Sun Feb 04 12:24:53 2007 -0700 69.3 @@ -103,7 +103,7 @@ 69.4 (hnd).p = val; \ 69.5 } while ( 0 ) 69.6 #define uint64_aligned_t uint64_t __attribute__((aligned(8))) 69.7 -#define XEN_GUEST_HANDLE_64(name) __guest_handle_64_ ## name 69.8 +#define XEN_GUEST_HANDLE_64(name) __guest_handle_64_ ## name __attribute__((aligned(8))) 69.9 #endif 69.10 69.11 #ifndef __ASSEMBLY__
70.1 --- a/xen/include/public/domctl.h Sun Feb 04 12:18:48 2007 -0700 70.2 +++ b/xen/include/public/domctl.h Sun Feb 04 12:24:53 2007 -0700 70.3 @@ -386,18 +386,11 @@ struct xen_domctl_settimeoffset { 70.4 typedef struct xen_domctl_settimeoffset xen_domctl_settimeoffset_t; 70.5 DEFINE_XEN_GUEST_HANDLE(xen_domctl_settimeoffset_t); 70.6 70.7 -#define HVM_CTXT_SIZE 8192 70.8 -typedef struct hvm_domain_context { 70.9 - uint32_t cur; 70.10 - uint32_t size; 70.11 - uint8_t data[HVM_CTXT_SIZE]; 70.12 -} hvm_domain_context_t; 70.13 -DEFINE_XEN_GUEST_HANDLE(hvm_domain_context_t); 70.14 - 70.15 #define XEN_DOMCTL_gethvmcontext 33 70.16 #define XEN_DOMCTL_sethvmcontext 34 70.17 typedef struct xen_domctl_hvmcontext { 70.18 - XEN_GUEST_HANDLE_64(hvm_domain_context_t) ctxt; /* IN/OUT */ 70.19 + uint32_t size; /* IN/OUT: size of buffer / bytes filled */ 70.20 + XEN_GUEST_HANDLE(uint8_t) buffer; /* IN/OUT */ 70.21 } xen_domctl_hvmcontext_t; 70.22 DEFINE_XEN_GUEST_HANDLE(xen_domctl_hvmcontext_t); 70.23
71.1 --- a/xen/include/public/foreign/Makefile Sun Feb 04 12:18:48 2007 -0700 71.2 +++ b/xen/include/public/foreign/Makefile Sun Feb 04 12:24:53 2007 -0700 71.3 @@ -13,9 +13,16 @@ clean: 71.4 rm -f checker checker.c $(XEN_TARGET_ARCH).size 71.5 rm -f *.pyc *.o *~ 71.6 71.7 +ifeq ($(CROSS_COMPILE),) 71.8 check-headers: checker 71.9 ./checker > $(XEN_TARGET_ARCH).size 71.10 diff -u reference.size $(XEN_TARGET_ARCH).size 71.11 +checker: checker.c $(headers) 71.12 + $(HOSTCC) $(CFLAGS) -o $@ $< 71.13 +else 71.14 +check-headers: 71.15 + @echo "cross build: skipping check" 71.16 +endif 71.17 71.18 x86_32.h: ../arch-x86/xen-x86_32.h ../arch-x86/xen.h ../xen.h $(scripts) 71.19 python mkheader.py $* $@ $(filter %.h,$^) 71.20 @@ -26,8 +33,5 @@ x86_64.h: ../arch-x86/xen-x86_64.h ../ar 71.21 ia64.h: ../arch-ia64.h ../xen.h $(scripts) 71.22 python mkheader.py $* $@ $(filter %.h,$^) 71.23 71.24 -checker: checker.c $(headers) 71.25 - $(HOSTCC) $(CFLAGS) -o $@ $< 71.26 - 71.27 checker.c: $(scripts) 71.28 python mkchecker.py $(XEN_TARGET_ARCH) $@ $(architectures)
72.1 --- a/xen/include/public/hvm/save.h Sun Feb 04 12:18:48 2007 -0700 72.2 +++ b/xen/include/public/hvm/save.h Sun Feb 04 12:24:53 2007 -0700 72.3 @@ -381,10 +381,40 @@ struct hvm_hw_rtc { 72.4 DECLARE_HVM_SAVE_TYPE(RTC, 9, struct hvm_hw_rtc); 72.5 72.6 72.7 +/* 72.8 + * HPET 72.9 + */ 72.10 + 72.11 +#define HPET_TIMER_NUM 3 /* 3 timers supported now */ 72.12 +struct hvm_hw_hpet { 72.13 + /* Memory-mapped, software visible registers */ 72.14 + uint64_t capability; /* capabilities */ 72.15 + uint64_t res0; /* reserved */ 72.16 + uint64_t config; /* configuration */ 72.17 + uint64_t res1; /* reserved */ 72.18 + uint64_t isr; /* interrupt status reg */ 72.19 + uint64_t res2[25]; /* reserved */ 72.20 + uint64_t mc64; /* main counter */ 72.21 + uint64_t res3; /* reserved */ 72.22 + struct { /* timers */ 72.23 + uint64_t config; /* configuration/cap */ 72.24 + uint64_t cmp; /* comparator */ 72.25 + uint64_t fsb; /* FSB route, not supported now */ 72.26 + uint64_t res4; /* reserved */ 72.27 + } timers[HPET_TIMER_NUM]; 72.28 + uint64_t res5[4*(24-HPET_TIMER_NUM)]; /* reserved, up to 0x3ff */ 72.29 + 72.30 + /* Hidden register state */ 72.31 + uint64_t period[HPET_TIMER_NUM]; /* Last value written to comparator */ 72.32 +}; 72.33 + 72.34 +DECLARE_HVM_SAVE_TYPE(HPET, 10, struct hvm_hw_hpet); 72.35 + 72.36 + 72.37 /* 72.38 * Largest type-code in use 72.39 */ 72.40 -#define HVM_SAVE_CODE_MAX 9 72.41 +#define HVM_SAVE_CODE_MAX 10 72.42 72.43 72.44 /*
73.1 --- a/xen/include/xen/string.h Sun Feb 04 12:18:48 2007 -0700 73.2 +++ b/xen/include/xen/string.h Sun Feb 04 12:24:53 2007 -0700 73.3 @@ -82,8 +82,16 @@ extern void * memchr(const void *,int,__ 73.4 } 73.5 #endif 73.6 73.7 +#define is_char_array(x) __builtin_types_compatible_p(typeof(x), char[]) 73.8 + 73.9 /* safe_xxx always NUL-terminates and returns !=0 if result is truncated. */ 73.10 -#define safe_strcpy(d, s) (strlcpy(d, s, sizeof(d)) >= sizeof(d)) 73.11 -#define safe_strcat(d, s) (strlcat(d, s, sizeof(d)) >= sizeof(d)) 73.12 +#define safe_strcpy(d, s) ({ \ 73.13 + BUILD_BUG_ON(!is_char_array(d)); \ 73.14 + (strlcpy(d, s, sizeof(d)) >= sizeof(d)); \ 73.15 +}) 73.16 +#define safe_strcat(d, s) ({ \ 73.17 + BUILD_BUG_ON(!is_char_array(d)); \ 73.18 + (strlcat(d, s, sizeof(d)) >= sizeof(d)); \ 73.19 +}) 73.20 73.21 #endif /* _LINUX_STRING_H_ */
74.1 --- a/xen/tools/get-fields.sh Sun Feb 04 12:18:48 2007 -0700 74.2 +++ b/xen/tools/get-fields.sh Sun Feb 04 12:24:53 2007 -0700 74.3 @@ -227,7 +227,7 @@ handle_array() { 74.4 74.5 build_body() { 74.6 echo 74.7 - echo -n "#define XLAT_$1(_d_, _s_)" 74.8 + echo -n "#define XLAT_$1(_d_, _s_) do {" 74.9 local level=1 fields= id= array= arrlvl=1 array_type= type= token 74.10 for token in $2 74.11 do 74.12 @@ -303,6 +303,8 @@ build_body() { 74.13 esac 74.14 test -z "$fields" || fields="$fields $token" 74.15 done 74.16 + echo " \\" 74.17 + echo "} while (0)" 74.18 echo "" 74.19 } 74.20