aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/Rules.mk5
-rw-r--r--tools/blktap/Makefile4
-rw-r--r--tools/firmware/rombios/tcgbios.c38
-rw-r--r--tools/libxc/xc_dom_boot.c50
-rw-r--r--tools/libxc/xc_dom_ia64.c11
-rw-r--r--tools/libxc/xc_hvm_restore.c26
-rw-r--r--tools/libxc/xc_hvm_save.c6
-rw-r--r--tools/libxc/xc_linux_save.c4
-rw-r--r--tools/libxen/include/xen_cpu_feature.h387
-rw-r--r--tools/libxen/include/xen_crashdump.h206
-rw-r--r--tools/libxen/include/xen_crashdump_decl.h (renamed from tools/libxen/include/xen_cpu_feature_internal.h)23
-rw-r--r--tools/libxen/include/xen_driver_type.h77
-rw-r--r--tools/libxen/include/xen_host.h115
-rw-r--r--tools/libxen/include/xen_host_cpu.h9
-rw-r--r--tools/libxen/include/xen_host_metrics.h193
-rw-r--r--tools/libxen/include/xen_host_metrics_decl.h (renamed from tools/libxen/include/xen_driver_type_internal.h)23
-rw-r--r--tools/libxen/include/xen_pbd.h216
-rw-r--r--tools/libxen/include/xen_pbd_decl.h30
-rw-r--r--tools/libxen/include/xen_pif.h68
-rw-r--r--tools/libxen/include/xen_pif_metrics.h192
-rw-r--r--tools/libxen/include/xen_pif_metrics_decl.h30
-rw-r--r--tools/libxen/include/xen_sr.h13
-rw-r--r--tools/libxen/include/xen_vbd.h37
-rw-r--r--tools/libxen/include/xen_vdi.h29
-rw-r--r--tools/libxen/include/xen_vdi_type.h12
-rw-r--r--tools/libxen/include/xen_vif.h49
-rw-r--r--tools/libxen/include/xen_vm.h195
-rw-r--r--tools/libxen/include/xen_vm_metrics.h201
-rw-r--r--tools/libxen/include/xen_vm_metrics_decl.h30
-rw-r--r--tools/libxen/include/xen_vtpm.h18
-rw-r--r--tools/libxen/src/xen_cpu_feature.c143
-rw-r--r--tools/libxen/src/xen_crashdump.c199
-rw-r--r--tools/libxen/src/xen_driver_type.c81
-rw-r--r--tools/libxen/src/xen_host.c263
-rw-r--r--tools/libxen/src/xen_host_cpu.c23
-rw-r--r--tools/libxen/src/xen_host_metrics.c172
-rw-r--r--tools/libxen/src/xen_pbd.c228
-rw-r--r--tools/libxen/src/xen_pif.c134
-rw-r--r--tools/libxen/src/xen_pif_metrics.c172
-rw-r--r--tools/libxen/src/xen_sr.c5
-rw-r--r--tools/libxen/src/xen_vbd.c70
-rw-r--r--tools/libxen/src/xen_vdi.c60
-rw-r--r--tools/libxen/src/xen_vdi_type.c4
-rw-r--r--tools/libxen/src/xen_vif.c104
-rw-r--r--tools/libxen/src/xen_vm.c350
-rw-r--r--tools/libxen/src/xen_vm_metrics.c194
-rw-r--r--tools/libxen/src/xen_vtpm.c38
-rw-r--r--tools/libxen/test/test_bindings.c21
-rw-r--r--tools/pygrub/src/fsimage/fsimage.c4
-rw-r--r--tools/python/scripts/test_hvm_create.py12
-rw-r--r--tools/python/scripts/test_vm_create.py13
-rw-r--r--tools/python/scripts/xapi.py12
-rw-r--r--tools/python/xen/xend/XendAPI.py546
-rw-r--r--tools/python/xen/xend/XendAPIConstants.py14
-rw-r--r--tools/python/xen/xend/XendAuthSessions.py9
-rw-r--r--tools/python/xen/xend/XendConfig.py175
-rw-r--r--tools/python/xen/xend/XendDomain.py23
-rw-r--r--tools/python/xen/xend/XendDomainInfo.py136
-rw-r--r--tools/python/xen/xend/XendError.py8
-rw-r--r--tools/python/xen/xend/XendNode.py80
-rw-r--r--tools/python/xen/xend/XendPIF.py54
-rw-r--r--tools/python/xen/xend/XendPIFMetrics.py47
-rw-r--r--tools/python/xen/xend/XendTask.py10
-rw-r--r--tools/python/xen/xend/XendTaskManager.py6
-rw-r--r--tools/python/xen/xend/XendVDI.py6
-rw-r--r--tools/python/xen/xend/image.py89
-rw-r--r--tools/python/xen/xend/server/ConsoleController.py6
-rw-r--r--tools/python/xen/xend/server/XMLRPCServer.py2
-rw-r--r--tools/python/xen/xend/server/vfbif.py69
-rw-r--r--tools/python/xen/xm/create.py6
-rw-r--r--tools/python/xen/xm/messages/en/xen-xm.po28
-rw-r--r--tools/security/Makefile3
-rw-r--r--tools/xenfb/Makefile2
-rw-r--r--tools/xm-test/tests/vtpm/09_vtpm-xapi.py121
74 files changed, 3980 insertions, 2059 deletions
diff --git a/tools/Rules.mk b/tools/Rules.mk
index 581b670568..af530ac65d 100644
--- a/tools/Rules.mk
+++ b/tools/Rules.mk
@@ -53,6 +53,9 @@ mk-symlinks-xen:
mkdir -p xen/arch-x86
( cd xen/arch-x86 && ln -sf ../../$(XEN_ROOT)/xen/include/public/arch-x86/*.h . )
mkdir -p xen/foreign
- ( cd xen/foreign && ln -sf ../../$(XEN_ROOT)/xen/include/public/foreign/*.h . )
+ ( cd xen/foreign && ln -sf ../../$(XEN_ROOT)/xen/include/public/foreign/Makefile . )
+ ( cd xen/foreign && ln -sf ../../$(XEN_ROOT)/xen/include/public/foreign/reference.size . )
+ ( cd xen/foreign && ln -sf ../../$(XEN_ROOT)/xen/include/public/foreign/*.py . )
+ make -C xen/foreign
mk-symlinks: mk-symlinks-xen mk-symlinks-$(XEN_OS)
diff --git a/tools/blktap/Makefile b/tools/blktap/Makefile
index fb194f3203..671c4f4b87 100644
--- a/tools/blktap/Makefile
+++ b/tools/blktap/Makefile
@@ -9,7 +9,7 @@ SUBDIRS-y += drivers
all: build
.PHONY: build
-build: mk-symlinks
+build:
@set -e; for subdir in $(SUBDIRS-y); do \
$(MAKE) -C $$subdir all; \
done
@@ -22,7 +22,7 @@ install:
.PHONY: clean
clean:
- rm -rf *.a *.so *.o *.rpm $(LIB) *~ $(DEPS) xen TAGS
+ rm -rf *.a *.so *.o *.rpm $(LIB) *~ $(DEPS) TAGS
@set -e; for subdir in $(SUBDIRS-y); do \
$(MAKE) -C $$subdir clean; \
done
diff --git a/tools/firmware/rombios/tcgbios.c b/tools/firmware/rombios/tcgbios.c
index 0f3668f89a..c8f5af2853 100644
--- a/tools/firmware/rombios/tcgbios.c
+++ b/tools/firmware/rombios/tcgbios.c
@@ -39,7 +39,7 @@ Bit32u tcpa_extend_acpi_log(entry_ptr)
Bit32u entry_ptr;
{
ASM_START
- DoUpcall IDX_TCPA_EXTEND_ACPI_LOG
+ DoUpcall(IDX_TCPA_EXTEND_ACPI_LOG)
ASM_END
}
@@ -52,7 +52,7 @@ Bit32u tcpa_extend_acpi_log(entry_ptr)
tcpa_acpi_init()
{
ASM_START
- DoUpcall IDX_TCPA_ACPI_INIT
+ DoUpcall(IDX_TCPA_ACPI_INIT)
ASM_END
}
@@ -64,7 +64,7 @@ tcpa_acpi_init()
tcpa_calling_int19h()
{
ASM_START
- DoUpcall IDX_TCPA_CALLING_INT19H
+ DoUpcall(IDX_TCPA_CALLING_INT19H)
ASM_END
}
@@ -75,7 +75,7 @@ tcpa_calling_int19h()
tcpa_returned_int19h()
{
ASM_START
- DoUpcall IDX_TCPA_RETURNED_INT19H
+ DoUpcall(IDX_TCPA_RETURNED_INT19H)
ASM_END
}
@@ -86,7 +86,7 @@ tcpa_returned_int19h()
tcpa_add_event_separators()
{
ASM_START
- DoUpcall IDX_TCPA_ADD_EVENT_SEPARATORS
+ DoUpcall(IDX_TCPA_ADD_EVENT_SEPARATORS)
ASM_END
}
@@ -98,7 +98,7 @@ tcpa_add_event_separators()
tcpa_wake_event()
{
ASM_START
- DoUpcall IDX_TCPA_WAKE_EVENT
+ DoUpcall(IDX_TCPA_WAKE_EVENT)
ASM_END
}
@@ -111,7 +111,7 @@ tcpa_wake_event()
tcpa_start_option_rom_scan()
{
ASM_START
- DoUpcall IDX_TCPA_START_OPTION_ROM_SCAN
+ DoUpcall(IDX_TCPA_START_OPTION_ROM_SCAN)
ASM_END
}
@@ -124,7 +124,7 @@ tcpa_option_rom(seg)
Bit32u seg;
{
ASM_START
- DoUpcall IDX_TCPA_OPTION_ROM
+ DoUpcall(IDX_TCPA_OPTION_ROM)
ASM_END
}
@@ -138,7 +138,7 @@ void
Bit32u bootdrv;
{
ASM_START
- DoUpcall IDX_TCPA_ADD_BOOTDEVICE
+ DoUpcall(IDX_TCPA_ADD_BOOTDEVICE)
ASM_END
}
@@ -154,7 +154,7 @@ tcpa_ipl(seg)
Bit32u seg;
{
ASM_START
- DoUpcall IDX_TCPA_IPL
+ DoUpcall(IDX_TCPA_IPL)
ASM_END
}
@@ -164,7 +164,7 @@ tcpa_initialize_tpm(physpres)
Bit32u physpres;
{
ASM_START
- DoUpcall IDX_TCPA_INITIALIZE_TPM
+ DoUpcall(IDX_TCPA_INITIALIZE_TPM)
ASM_END
}
@@ -174,7 +174,7 @@ tcpa_measure_post(from, to)
Bit32u to;
{
ASM_START
- DoUpcall IDX_TCPA_MEASURE_POST
+ DoUpcall(IDX_TCPA_MEASURE_POST)
ASM_END
}
@@ -194,12 +194,12 @@ tcpa_do_measure_POSTs()
{
ASM_START
- POST_MEASURE post, nmi
- POST_MEASURE floppy_drive_post, hard_drive_post
- POST_MEASURE hard_drive_post, ebda_post
- POST_MEASURE ebda_post, eoi_jmp_post
- POST_MEASURE eoi_jmp_post, timer_tick_post
- POST_MEASURE timer_tick_post, int76_handler
+ POST_MEASURE(post, nmi)
+ POST_MEASURE(floppy_drive_post, hard_drive_post)
+ POST_MEASURE(hard_drive_post, ebda_post)
+ POST_MEASURE(ebda_post, eoi_jmp_post)
+ POST_MEASURE(eoi_jmp_post, timer_tick_post)
+ POST_MEASURE(timer_tick_post, int76_handler)
ret
ASM_END
@@ -213,7 +213,7 @@ TCGInterruptHandler(regs_ptr, es, ds, flags_ptr)
Bit32u flags_ptr;
{
ASM_START
- DoUpcall IDX_TCGINTERRUPTHANDLER
+ DoUpcall(IDX_TCGINTERRUPTHANDLER)
ASM_END
}
diff --git a/tools/libxc/xc_dom_boot.c b/tools/libxc/xc_dom_boot.c
index 44d46e3f66..d8bfe485d8 100644
--- a/tools/libxc/xc_dom_boot.c
+++ b/tools/libxc/xc_dom_boot.c
@@ -157,6 +157,12 @@ static int arch_setup_early(struct xc_dom_image *dom)
return rc;
}
+static int arch_setup_middle(struct xc_dom_image *dom)
+{
+ xc_dom_printf("%s: doing nothing\n", __FUNCTION__);
+ return 0;
+}
+
static int arch_setup_late(struct xc_dom_image *dom)
{
static const struct {
@@ -259,6 +265,12 @@ static int arch_setup_late(struct xc_dom_image *dom)
static int arch_setup_early(struct xc_dom_image *dom)
{
+ xc_dom_printf("%s: doing nothing\n", __FUNCTION__);
+ return 0;
+}
+
+static int arch_setup_middle(struct xc_dom_image *dom)
+{
DECLARE_DOMCTL;
int rc;
@@ -268,16 +280,35 @@ static int arch_setup_early(struct xc_dom_image *dom)
domctl.cmd = XEN_DOMCTL_arch_setup;
domctl.domain = dom->guest_domid;
domctl.u.arch_setup.flags = 0;
+
+ /* dom->start_info_pfn should be initialized by alloc_magic_pages().
+ * However it is called later. So we initialize here.
+ */
+ dom->start_info_pfn = dom->total_pages - 3;
domctl.u.arch_setup.bp = (dom->start_info_pfn << PAGE_SHIFT)
+ sizeof(start_info_t);
- domctl.u.arch_setup.maxmem = dom->total_pages << PAGE_SHIFT;
+ /* 3 = start info page, xenstore page and console page */
+ domctl.u.arch_setup.maxmem = (dom->total_pages - 3) << PAGE_SHIFT;
rc = do_domctl(dom->guest_xc, &domctl);
return rc;
}
static int arch_setup_late(struct xc_dom_image *dom)
{
- xc_dom_printf("%s: doing nothing\n", __FUNCTION__);
+ unsigned int page_size = XC_DOM_PAGE_SIZE(dom);
+ shared_info_t *shared_info;
+
+ /* setup shared_info page */
+ xc_dom_printf("%s: shared_info: mfn 0x%" PRIpfn "\n",
+ __FUNCTION__, dom->shared_info_mfn);
+ shared_info = xc_map_foreign_range(dom->guest_xc, dom->guest_domid,
+ page_size,
+ PROT_READ | PROT_WRITE,
+ dom->shared_info_mfn);
+ if (NULL == shared_info)
+ return -1;
+ dom->arch_hooks->shared_info(dom, shared_info);
+ munmap(shared_info, page_size);
return 0;
}
@@ -292,6 +323,12 @@ static int arch_setup_early(struct xc_dom_image *dom)
return 0;
}
+static int arch_setup_middle(struct xc_dom_image *dom)
+{
+ xc_dom_printf("%s: doing nothing\n", __FUNCTION__);
+ return 0;
+}
+
static int arch_setup_late(struct xc_dom_image *dom)
{
start_info_t *si =
@@ -324,6 +361,12 @@ static int arch_setup_early(struct xc_dom_image *dom)
return 0;
}
+static int arch_setup_middle(struct xc_dom_image *dom)
+{
+ xc_dom_printf("%s: doing nothing\n", __FUNCTION__);
+ return 0;
+}
+
static int arch_setup_late(struct xc_dom_image *dom)
{
xc_dom_printf("%s: doing nothing\n", __FUNCTION__);
@@ -395,6 +438,9 @@ int xc_dom_boot_mem_init(struct xc_dom_image *dom)
return rc;
}
+ if (0 != (rc = arch_setup_middle(dom)))
+ return rc;
+
return 0;
}
diff --git a/tools/libxc/xc_dom_ia64.c b/tools/libxc/xc_dom_ia64.c
index 7214c3c299..c6e4424515 100644
--- a/tools/libxc/xc_dom_ia64.c
+++ b/tools/libxc/xc_dom_ia64.c
@@ -26,7 +26,11 @@ static int alloc_magic_pages(struct xc_dom_image *dom)
/* allocate special pages */
dom->console_pfn = dom->total_pages -1;
dom->xenstore_pfn = dom->total_pages -2;
- dom->start_info_pfn = dom->total_pages -3;
+
+ /*
+ * this is initialized by arch_setup_middle().
+ * dom->start_info_pfn = dom->total_pages -3;
+ */
return 0;
}
@@ -39,6 +43,7 @@ static int start_info_ia64(struct xc_dom_image *dom)
xc_dom_printf("%s\n", __FUNCTION__);
+ memset(start_info, 0, sizeof(*start_info));
sprintf(start_info->magic, dom->guest_type);
start_info->flags = dom->flags;
start_info->nr_pages = dom->total_pages;
@@ -54,12 +59,12 @@ static int start_info_ia64(struct xc_dom_image *dom)
bp->initrd_start = start_info->mod_start;
bp->initrd_size = start_info->mod_len;
}
+ bp->command_line = (dom->start_info_pfn << PAGE_SHIFT_IA64)
+ + offsetof(start_info_t, cmd_line);
if (dom->cmdline)
{
strncpy((char *)start_info->cmd_line, dom->cmdline, MAX_GUEST_CMDLINE);
start_info->cmd_line[MAX_GUEST_CMDLINE - 1] = '\0';
- bp->command_line = (dom->start_info_pfn << PAGE_SHIFT_IA64)
- + offsetof(start_info_t, cmd_line);
}
return 0;
}
diff --git a/tools/libxc/xc_hvm_restore.c b/tools/libxc/xc_hvm_restore.c
index 7092d5cea8..b2b9999fea 100644
--- a/tools/libxc/xc_hvm_restore.c
+++ b/tools/libxc/xc_hvm_restore.c
@@ -98,6 +98,8 @@ int xc_hvm_restore(int xc_handle, int io_fd,
/* Types of the pfns in the current region */
unsigned long region_pfn_type[MAX_BATCH_SIZE];
+ struct xen_add_to_physmap xatp;
+
/* hvm guest mem size (Mb) */
memsize = (unsigned long long)*store_mfn;
v_end = memsize << 20;
@@ -134,15 +136,6 @@ int xc_hvm_restore(int xc_handle, int io_fd,
goto out;
}
- /* Get the domain's shared-info frame. */
- domctl.cmd = XEN_DOMCTL_getdomaininfo;
- domctl.domain = (domid_t)dom;
- if (xc_domctl(xc_handle, &domctl) < 0) {
- ERROR("Could not get information on new domain");
- goto out;
- }
- shared_info_frame = domctl.u.getdomaininfo.shared_info_frame;
-
if(xc_domain_setmaxmem(xc_handle, dom, PFN_TO_KB(max_pfn)) != 0) {
errno = ENOMEM;
goto out;
@@ -346,6 +339,21 @@ int xc_hvm_restore(int xc_handle, int io_fd,
}
}
+ /* Shared-info pfn */
+ if (!read_exact(io_fd, &(shared_info_frame), sizeof(uint32_t)) ) {
+ ERROR("reading the shared-info pfn failed!\n");
+ goto out;
+ }
+ /* Map the shared-info frame where it was before */
+ xatp.domid = dom;
+ xatp.space = XENMAPSPACE_shared_info;
+ xatp.idx = 0;
+ xatp.gpfn = shared_info_frame;
+ if ( (rc = xc_memory_op(xc_handle, XENMEM_add_to_physmap, &xatp)) != 0 ) {
+ ERROR("setting the shared-info pfn failed!\n");
+ goto out;
+ }
+
rc = 0;
goto out;
diff --git a/tools/libxc/xc_hvm_save.c b/tools/libxc/xc_hvm_save.c
index aa6ad5a930..3d08a509d9 100644
--- a/tools/libxc/xc_hvm_save.c
+++ b/tools/libxc/xc_hvm_save.c
@@ -702,6 +702,12 @@ int xc_hvm_save(int xc_handle, int io_fd, uint32_t dom, uint32_t max_iters,
goto out;
}
}
+
+ /* Shared-info pfn */
+ if (!write_exact(io_fd, &(shared_info_frame), sizeof(uint32_t)) ) {
+ ERROR("write shared-info pfn failed!\n");
+ goto out;
+ }
/* Success! */
rc = 0;
diff --git a/tools/libxc/xc_linux_save.c b/tools/libxc/xc_linux_save.c
index e6c1799d7c..de1c605002 100644
--- a/tools/libxc/xc_linux_save.c
+++ b/tools/libxc/xc_linux_save.c
@@ -998,7 +998,7 @@ int xc_linux_save(int xc_handle, int io_fd, uint32_t dom, uint32_t max_iters,
}
for ( j = 0; j < batch; j++ )
- ((uint32_t *)pfn_type)[i] = pfn_type[i];
+ ((uint32_t *)pfn_type)[j] = pfn_type[j];
if ( xc_get_pfn_type_batch(xc_handle, dom, batch,
(uint32_t *)pfn_type) )
{
@@ -1006,7 +1006,7 @@ int xc_linux_save(int xc_handle, int io_fd, uint32_t dom, uint32_t max_iters,
goto out;
}
for ( j = batch-1; j >= 0; j-- )
- pfn_type[i] = ((uint32_t *)pfn_type)[i];
+ pfn_type[j] = ((uint32_t *)pfn_type)[j];
for ( j = 0; j < batch; j++ )
{
diff --git a/tools/libxen/include/xen_cpu_feature.h b/tools/libxen/include/xen_cpu_feature.h
deleted file mode 100644
index 57a34d2773..0000000000
--- a/tools/libxen/include/xen_cpu_feature.h
+++ /dev/null
@@ -1,387 +0,0 @@
-/*
- * Copyright (c) 2006, XenSource Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef XEN_CPU_FEATURE_H
-#define XEN_CPU_FEATURE_H
-
-
-#include "xen_common.h"
-
-
-enum xen_cpu_feature
-{
- /**
- * Onboard FPU
- */
- XEN_CPU_FEATURE_FPU,
-
- /**
- * Virtual Mode Extensions
- */
- XEN_CPU_FEATURE_VME,
-
- /**
- * Debugging Extensions
- */
- XEN_CPU_FEATURE_DE,
-
- /**
- * Page Size Extensions
- */
- XEN_CPU_FEATURE_PSE,
-
- /**
- * Time Stamp Counter
- */
- XEN_CPU_FEATURE_TSC,
-
- /**
- * Model-Specific Registers, RDMSR, WRMSR
- */
- XEN_CPU_FEATURE_MSR,
-
- /**
- * Physical Address Extensions
- */
- XEN_CPU_FEATURE_PAE,
-
- /**
- * Machine Check Architecture
- */
- XEN_CPU_FEATURE_MCE,
-
- /**
- * CMPXCHG8 instruction
- */
- XEN_CPU_FEATURE_CX8,
-
- /**
- * Onboard APIC
- */
- XEN_CPU_FEATURE_APIC,
-
- /**
- * SYSENTER/SYSEXIT
- */
- XEN_CPU_FEATURE_SEP,
-
- /**
- * Memory Type Range Registers
- */
- XEN_CPU_FEATURE_MTRR,
-
- /**
- * Page Global Enable
- */
- XEN_CPU_FEATURE_PGE,
-
- /**
- * Machine Check Architecture
- */
- XEN_CPU_FEATURE_MCA,
-
- /**
- * CMOV instruction (FCMOVCC and FCOMI too if FPU present)
- */
- XEN_CPU_FEATURE_CMOV,
-
- /**
- * Page Attribute Table
- */
- XEN_CPU_FEATURE_PAT,
-
- /**
- * 36-bit PSEs
- */
- XEN_CPU_FEATURE_PSE36,
-
- /**
- * Processor serial number
- */
- XEN_CPU_FEATURE_PN,
-
- /**
- * Supports the CLFLUSH instruction
- */
- XEN_CPU_FEATURE_CLFLSH,
-
- /**
- * Debug Trace Store
- */
- XEN_CPU_FEATURE_DTES,
-
- /**
- * ACPI via MSR
- */
- XEN_CPU_FEATURE_ACPI,
-
- /**
- * Multimedia Extensions
- */
- XEN_CPU_FEATURE_MMX,
-
- /**
- * FXSAVE and FXRSTOR instructions (fast save and restore
- */
- XEN_CPU_FEATURE_FXSR,
-
- /**
- * Streaming SIMD Extensions
- */
- XEN_CPU_FEATURE_XMM,
-
- /**
- * Streaming SIMD Extensions-2
- */
- XEN_CPU_FEATURE_XMM2,
-
- /**
- * CPU self snoop
- */
- XEN_CPU_FEATURE_SELFSNOOP,
-
- /**
- * Hyper-Threading
- */
- XEN_CPU_FEATURE_HT,
-
- /**
- * Automatic clock control
- */
- XEN_CPU_FEATURE_ACC,
-
- /**
- * IA-64 processor
- */
- XEN_CPU_FEATURE_IA64,
-
- /**
- * SYSCALL/SYSRET
- */
- XEN_CPU_FEATURE_SYSCALL,
-
- /**
- * MP Capable.
- */
- XEN_CPU_FEATURE_MP,
-
- /**
- * Execute Disable
- */
- XEN_CPU_FEATURE_NX,
-
- /**
- * AMD MMX extensions
- */
- XEN_CPU_FEATURE_MMXEXT,
-
- /**
- * Long Mode (x86-64)
- */
- XEN_CPU_FEATURE_LM,
-
- /**
- * AMD 3DNow! extensions
- */
- XEN_CPU_FEATURE_THREEDNOWEXT,
-
- /**
- * 3DNow!
- */
- XEN_CPU_FEATURE_THREEDNOW,
-
- /**
- * CPU in recovery mode
- */
- XEN_CPU_FEATURE_RECOVERY,
-
- /**
- * Longrun power control
- */
- XEN_CPU_FEATURE_LONGRUN,
-
- /**
- * LongRun table interface
- */
- XEN_CPU_FEATURE_LRTI,
-
- /**
- * Cyrix MMX extensions
- */
- XEN_CPU_FEATURE_CXMMX,
-
- /**
- * AMD K6 nonstandard MTRRs
- */
- XEN_CPU_FEATURE_K6_MTRR,
-
- /**
- * Cyrix ARRs (= MTRRs)
- */
- XEN_CPU_FEATURE_CYRIX_ARR,
-
- /**
- * Centaur MCRs (= MTRRs)
- */
- XEN_CPU_FEATURE_CENTAUR_MCR,
-
- /**
- * Opteron, Athlon64
- */
- XEN_CPU_FEATURE_K8,
-
- /**
- * Athlon
- */
- XEN_CPU_FEATURE_K7,
-
- /**
- * P3
- */
- XEN_CPU_FEATURE_P3,
-
- /**
- * P4
- */
- XEN_CPU_FEATURE_P4,
-
- /**
- * TSC ticks at a constant rate
- */
- XEN_CPU_FEATURE_CONSTANT_TSC,
-
- /**
- * FXSAVE leaks FOP/FIP/FOP
- */
- XEN_CPU_FEATURE_FXSAVE_LEAK,
-
- /**
- * Streaming SIMD Extensions-3
- */
- XEN_CPU_FEATURE_XMM3,
-
- /**
- * Monitor/Mwait support
- */
- XEN_CPU_FEATURE_MWAIT,
-
- /**
- * CPL Qualified Debug Store
- */
- XEN_CPU_FEATURE_DSCPL,
-
- /**
- * Enhanced SpeedStep
- */
- XEN_CPU_FEATURE_EST,
-
- /**
- * Thermal Monitor 2
- */
- XEN_CPU_FEATURE_TM2,
-
- /**
- * Context ID
- */
- XEN_CPU_FEATURE_CID,
-
- /**
- * CMPXCHG16B
- */
- XEN_CPU_FEATURE_CX16,
-
- /**
- * Send Task Priority Messages
- */
- XEN_CPU_FEATURE_XTPR,
-
- /**
- * on-CPU RNG present (xstore insn)
- */
- XEN_CPU_FEATURE_XSTORE,
-
- /**
- * on-CPU RNG enabled
- */
- XEN_CPU_FEATURE_XSTORE_EN,
-
- /**
- * on-CPU crypto (xcrypt insn)
- */
- XEN_CPU_FEATURE_XCRYPT,
-
- /**
- * on-CPU crypto enabled
- */
- XEN_CPU_FEATURE_XCRYPT_EN,
-
- /**
- * LAHF/SAHF in long mode
- */
- XEN_CPU_FEATURE_LAHF_LM,
-
- /**
- * If yes HyperThreading not valid
- */
- XEN_CPU_FEATURE_CMP_LEGACY,
-
- /**
- * VMX instruction set
- */
- XEN_CPU_FEATURE_VMX
-};
-
-
-typedef struct xen_cpu_feature_set
-{
- size_t size;
- enum xen_cpu_feature contents[];
-} xen_cpu_feature_set;
-
-/**
- * Allocate a xen_cpu_feature_set of the given size.
- */
-extern xen_cpu_feature_set *
-xen_cpu_feature_set_alloc(size_t size);
-
-/**
- * Free the given xen_cpu_feature_set. The given set must have been
- * allocated by this library.
- */
-extern void
-xen_cpu_feature_set_free(xen_cpu_feature_set *set);
-
-
-/**
- * Return the name corresponding to the given code. This string must
- * not be modified or freed.
- */
-extern const char *
-xen_cpu_feature_to_string(enum xen_cpu_feature val);
-
-
-/**
- * Return the correct code for the given string, or set the session
- * object to failure and return an undefined value if the given string does
- * not match a known code.
- */
-extern enum xen_cpu_feature
-xen_cpu_feature_from_string(xen_session *session, const char *str);
-
-
-#endif
diff --git a/tools/libxen/include/xen_crashdump.h b/tools/libxen/include/xen_crashdump.h
new file mode 100644
index 0000000000..fff0a1a144
--- /dev/null
+++ b/tools/libxen/include/xen_crashdump.h
@@ -0,0 +1,206 @@
+/*
+ * Copyright (c) 2006, XenSource Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef XEN_CRASHDUMP_H
+#define XEN_CRASHDUMP_H
+
+#include "xen_common.h"
+#include "xen_crashdump_decl.h"
+#include "xen_vdi_decl.h"
+#include "xen_vm_decl.h"
+
+
+/*
+ * The crashdump class.
+ *
+ * A VM crashdump.
+ */
+
+
+/**
+ * Free the given xen_crashdump. The given handle must have been
+ * allocated by this library.
+ */
+extern void
+xen_crashdump_free(xen_crashdump crashdump);
+
+
+typedef struct xen_crashdump_set
+{
+ size_t size;
+ xen_crashdump *contents[];
+} xen_crashdump_set;
+
+/**
+ * Allocate a xen_crashdump_set of the given size.
+ */
+extern xen_crashdump_set *
+xen_crashdump_set_alloc(size_t size);
+
+/**
+ * Free the given xen_crashdump_set. The given set must have been
+ * allocated by this library.
+ */
+extern void
+xen_crashdump_set_free(xen_crashdump_set *set);
+
+
+typedef struct xen_crashdump_record
+{
+ xen_crashdump handle;
+ char *uuid;
+ struct xen_vm_record_opt *vm;
+ struct xen_vdi_record_opt *vdi;
+} xen_crashdump_record;
+
+/**
+ * Allocate a xen_crashdump_record.
+ */
+extern xen_crashdump_record *
+xen_crashdump_record_alloc(void);
+
+/**
+ * Free the given xen_crashdump_record, and all referenced values. The
+ * given record must have been allocated by this library.
+ */
+extern void
+xen_crashdump_record_free(xen_crashdump_record *record);
+
+
+typedef struct xen_crashdump_record_opt
+{
+ bool is_record;
+ union
+ {
+ xen_crashdump handle;
+ xen_crashdump_record *record;
+ } u;
+} xen_crashdump_record_opt;
+
+/**
+ * Allocate a xen_crashdump_record_opt.
+ */
+extern xen_crashdump_record_opt *
+xen_crashdump_record_opt_alloc(void);
+
+/**
+ * Free the given xen_crashdump_record_opt, and all referenced values.
+ * The given record_opt must have been allocated by this library.
+ */
+extern void
+xen_crashdump_record_opt_free(xen_crashdump_record_opt *record_opt);
+
+
+typedef struct xen_crashdump_record_set
+{
+ size_t size;
+ xen_crashdump_record *contents[];
+} xen_crashdump_record_set;
+
+/**
+ * Allocate a xen_crashdump_record_set of the given size.
+ */
+extern xen_crashdump_record_set *
+xen_crashdump_record_set_alloc(size_t size);
+
+/**
+ * Free the given xen_crashdump_record_set, and all referenced values.
+ * The given set must have been allocated by this library.
+ */
+extern void
+xen_crashdump_record_set_free(xen_crashdump_record_set *set);
+
+
+
+typedef struct xen_crashdump_record_opt_set
+{
+ size_t size;
+ xen_crashdump_record_opt *contents[];
+} xen_crashdump_record_opt_set;
+
+/**
+ * Allocate a xen_crashdump_record_opt_set of the given size.
+ */
+extern xen_crashdump_record_opt_set *
+xen_crashdump_record_opt_set_alloc(size_t size);
+
+/**
+ * Free the given xen_crashdump_record_opt_set, and all referenced
+ * values. The given set must have been allocated by this library.
+ */
+extern void
+xen_crashdump_record_opt_set_free(xen_crashdump_record_opt_set *set);
+
+
+/**
+ * Get a record containing the current state of the given crashdump.
+ */
+extern bool
+xen_crashdump_get_record(xen_session *session, xen_crashdump_record **result, xen_crashdump crashdump);
+
+
+/**
+ * Get a reference to the crashdump instance with the specified UUID.
+ */
+extern bool
+xen_crashdump_get_by_uuid(xen_session *session, xen_crashdump *result, char *uuid);
+
+
+/**
+ * Create a new crashdump instance, and return its handle.
+ */
+extern bool
+xen_crashdump_create(xen_session *session, xen_crashdump *result, xen_crashdump_record *record);
+
+
+/**
+ * Destroy the specified crashdump instance.
+ */
+extern bool
+xen_crashdump_destroy(xen_session *session, xen_crashdump crashdump);
+
+
+/**
+ * Get the uuid field of the given crashdump.
+ */
+extern bool
+xen_crashdump_get_uuid(xen_session *session, char **result, xen_crashdump crashdump);
+
+
+/**
+ * Get the VM field of the given crashdump.
+ */
+extern bool
+xen_crashdump_get_vm(xen_session *session, xen_vm *result, xen_crashdump crashdump);
+
+
+/**
+ * Get the VDI field of the given crashdump.
+ */
+extern bool
+xen_crashdump_get_vdi(xen_session *session, xen_vdi *result, xen_crashdump crashdump);
+
+
+/**
+ * Return a list of all the crashdumps known to the system.
+ */
+extern bool
+xen_crashdump_get_all(xen_session *session, struct xen_crashdump_set **result);
+
+
+#endif
diff --git a/tools/libxen/include/xen_cpu_feature_internal.h b/tools/libxen/include/xen_crashdump_decl.h
index c4616a7c5f..3087715c4f 100644
--- a/tools/libxen/include/xen_cpu_feature_internal.h
+++ b/tools/libxen/include/xen_crashdump_decl.h
@@ -16,22 +16,15 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#ifndef XEN_CRASHDUMP_DECL_H
+#define XEN_CRASHDUMP_DECL_H
-/*
- * Declarations of the abstract types used during demarshalling of enum
- * xen_cpu_feature. Internal to this library -- do not use from outside.
- */
-
-
-#ifndef XEN_CPU_FEATURE_INTERNAL_H
-#define XEN_CPU_FEATURE_INTERNAL_H
-
-
-#include "xen_internal.h"
-
-
-extern const abstract_type xen_cpu_feature_abstract_type_;
-extern const abstract_type xen_cpu_feature_set_abstract_type_;
+typedef void *xen_crashdump;
+struct xen_crashdump_set;
+struct xen_crashdump_record;
+struct xen_crashdump_record_set;
+struct xen_crashdump_record_opt;
+struct xen_crashdump_record_opt_set;
#endif
diff --git a/tools/libxen/include/xen_driver_type.h b/tools/libxen/include/xen_driver_type.h
deleted file mode 100644
index 585db28979..0000000000
--- a/tools/libxen/include/xen_driver_type.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (c) 2006, XenSource Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef XEN_DRIVER_TYPE_H
-#define XEN_DRIVER_TYPE_H
-
-
-#include "xen_common.h"
-
-
-enum xen_driver_type
-{
- /**
- * use hardware emulation
- */
- XEN_DRIVER_TYPE_IOEMU,
-
- /**
- * use paravirtualised driver
- */
- XEN_DRIVER_TYPE_PARAVIRTUALISED
-};
-
-
-typedef struct xen_driver_type_set
-{
- size_t size;
- enum xen_driver_type contents[];
-} xen_driver_type_set;
-
-/**
- * Allocate a xen_driver_type_set of the given size.
- */
-extern xen_driver_type_set *
-xen_driver_type_set_alloc(size_t size);
-
-/**
- * Free the given xen_driver_type_set. The given set must have been
- * allocated by this library.
- */
-extern void
-xen_driver_type_set_free(xen_driver_type_set *set);
-
-
-/**
- * Return the name corresponding to the given code. This string must
- * not be modified or freed.
- */
-extern const char *
-xen_driver_type_to_string(enum xen_driver_type val);
-
-
-/**
- * Return the correct code for the given string, or set the session
- * object to failure and return an undefined value if the given string does
- * not match a known code.
- */
-extern enum xen_driver_type
-xen_driver_type_from_string(xen_session *session, const char *str);
-
-
-#endif
diff --git a/tools/libxen/include/xen_host.h b/tools/libxen/include/xen_host.h
index 5b1a4dca8a..e64390b89f 100644
--- a/tools/libxen/include/xen_host.h
+++ b/tools/libxen/include/xen_host.h
@@ -22,14 +22,17 @@
#include "xen_common.h"
#include "xen_host_cpu_decl.h"
#include "xen_host_decl.h"
+#include "xen_host_metrics_decl.h"
+#include "xen_pbd_decl.h"
#include "xen_pif_decl.h"
+#include "xen_sr_decl.h"
#include "xen_string_string_map.h"
#include "xen_vm_decl.h"
/*
- * The host class.
- *
+ * The host class.
+ *
* A physical host.
*/
@@ -69,9 +72,15 @@ typedef struct xen_host_record
char *name_label;
char *name_description;
xen_string_string_map *software_version;
+ xen_string_string_map *other_config;
struct xen_vm_record_opt_set *resident_vms;
+ xen_string_string_map *logging;
struct xen_pif_record_opt_set *pifs;
+ struct xen_sr_record_opt *suspend_image_sr;
+ struct xen_sr_record_opt *crash_dump_sr;
+ struct xen_pbd_record_opt_set *pbds;
struct xen_host_cpu_record_opt_set *host_cpus;
+ struct xen_host_metrics_record_opt *metrics;
} xen_host_record;
/**
@@ -217,6 +226,13 @@ xen_host_get_software_version(xen_session *session, xen_string_string_map **resu
/**
+ * Get the other_config field of the given host.
+ */
+extern bool
+xen_host_get_other_config(xen_session *session, xen_string_string_map **result, xen_host host);
+
+
+/**
* Get the resident_VMs field of the given host.
*/
extern bool
@@ -224,6 +240,13 @@ xen_host_get_resident_vms(xen_session *session, struct xen_vm_set **result, xen_
/**
+ * Get the logging field of the given host.
+ */
+extern bool
+xen_host_get_logging(xen_session *session, xen_string_string_map **result, xen_host host);
+
+
+/**
* Get the PIFs field of the given host.
*/
extern bool
@@ -231,6 +254,27 @@ xen_host_get_pifs(xen_session *session, struct xen_pif_set **result, xen_host ho
/**
+ * Get the suspend_image_sr field of the given host.
+ */
+extern bool
+xen_host_get_suspend_image_sr(xen_session *session, xen_sr *result, xen_host host);
+
+
+/**
+ * Get the crash_dump_sr field of the given host.
+ */
+extern bool
+xen_host_get_crash_dump_sr(xen_session *session, xen_sr *result, xen_host host);
+
+
+/**
+ * Get the PBDs field of the given host.
+ */
+extern bool
+xen_host_get_pbds(xen_session *session, struct xen_pbd_set **result, xen_host host);
+
+
+/**
* Get the host_CPUs field of the given host.
*/
extern bool
@@ -238,6 +282,13 @@ xen_host_get_host_cpus(xen_session *session, struct xen_host_cpu_set **result, x
/**
+ * Get the metrics field of the given host.
+ */
+extern bool
+xen_host_get_metrics(xen_session *session, xen_host_metrics *result, xen_host host);
+
+
+/**
* Set the name/label field of the given host.
*/
extern bool
@@ -252,6 +303,66 @@ xen_host_set_name_description(xen_session *session, xen_host host, char *descrip
/**
+ * Set the other_config field of the given host.
+ */
+extern bool
+xen_host_set_other_config(xen_session *session, xen_host host, xen_string_string_map *other_config);
+
+
+/**
+ * Add the given key-value pair to the other_config field of the given
+ * host.
+ */
+extern bool
+xen_host_add_to_other_config(xen_session *session, xen_host host, char *key, char *value);
+
+
+/**
+ * Remove the given key and its corresponding value from the
+ * other_config field of the given host. If the key is not in that Map, then
+ * do nothing.
+ */
+extern bool
+xen_host_remove_from_other_config(xen_session *session, xen_host host, char *key);
+
+
+/**
+ * Set the logging field of the given host.
+ */
+extern bool
+xen_host_set_logging(xen_session *session, xen_host host, xen_string_string_map *logging);
+
+
+/**
+ * Add the given key-value pair to the logging field of the given host.
+ */
+extern bool
+xen_host_add_to_logging(xen_session *session, xen_host host, char *key, char *value);
+
+
+/**
+ * Remove the given key and its corresponding value from the logging
+ * field of the given host. If the key is not in that Map, then do nothing.
+ */
+extern bool
+xen_host_remove_from_logging(xen_session *session, xen_host host, char *key);
+
+
+/**
+ * Set the suspend_image_sr field of the given host.
+ */
+extern bool
+xen_host_set_suspend_image_sr(xen_session *session, xen_host host, xen_sr suspend_image_sr);
+
+
+/**
+ * Set the crash_dump_sr field of the given host.
+ */
+extern bool
+xen_host_set_crash_dump_sr(xen_session *session, xen_host host, xen_sr crash_dump_sr);
+
+
+/**
* Puts the host into a state in which no new VMs can be started.
* Currently active VMs on the host continue to execute.
*/
diff --git a/tools/libxen/include/xen_host_cpu.h b/tools/libxen/include/xen_host_cpu.h
index 15aee488d4..945a7279d1 100644
--- a/tools/libxen/include/xen_host_cpu.h
+++ b/tools/libxen/include/xen_host_cpu.h
@@ -20,7 +20,6 @@
#define XEN_HOST_CPU_H
#include "xen_common.h"
-#include "xen_cpu_feature.h"
#include "xen_host_cpu_decl.h"
#include "xen_host_decl.h"
@@ -69,7 +68,6 @@ typedef struct xen_host_cpu_record
char *vendor;
int64_t speed;
char *modelname;
- struct xen_cpu_feature_set *features;
double utilisation;
} xen_host_cpu_record;
@@ -223,13 +221,6 @@ xen_host_cpu_get_modelname(xen_session *session, char **result, xen_host_cpu hos
/**
- * Get the features field of the given host_cpu.
- */
-extern bool
-xen_host_cpu_get_features(xen_session *session, struct xen_cpu_feature_set **result, xen_host_cpu host_cpu);
-
-
-/**
* Get the utilisation field of the given host_cpu.
*/
extern bool
diff --git a/tools/libxen/include/xen_host_metrics.h b/tools/libxen/include/xen_host_metrics.h
new file mode 100644
index 0000000000..6ee609a9e9
--- /dev/null
+++ b/tools/libxen/include/xen_host_metrics.h
@@ -0,0 +1,193 @@
+/*
+ * Copyright (c) 2006, XenSource Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef XEN_HOST_METRICS_H
+#define XEN_HOST_METRICS_H
+
+#include "xen_common.h"
+#include "xen_host_decl.h"
+#include "xen_host_metrics_decl.h"
+
+
+/*
+ * The host_metrics class.
+ *
+ * The metrics associated with a host.
+ */
+
+
+/**
+ * Free the given xen_host_metrics. The given handle must have been
+ * allocated by this library.
+ */
+extern void
+xen_host_metrics_free(xen_host_metrics host_metrics);
+
+
+typedef struct xen_host_metrics_set
+{
+ size_t size;
+ xen_host_metrics *contents[];
+} xen_host_metrics_set;
+
+/**
+ * Allocate a xen_host_metrics_set of the given size.
+ */
+extern xen_host_metrics_set *
+xen_host_metrics_set_alloc(size_t size);
+
+/**
+ * Free the given xen_host_metrics_set. The given set must have been
+ * allocated by this library.
+ */
+extern void
+xen_host_metrics_set_free(xen_host_metrics_set *set);
+
+
+typedef struct xen_host_metrics_record
+{
+ xen_host_metrics handle;
+ char *uuid;
+ struct xen_host_record_opt *host;
+ int64_t memory_total;
+ int64_t memory_free;
+} xen_host_metrics_record;
+
+/**
+ * Allocate a xen_host_metrics_record.
+ */
+extern xen_host_metrics_record *
+xen_host_metrics_record_alloc(void);
+
+/**
+ * Free the given xen_host_metrics_record, and all referenced values.
+ * The given record must have been allocated by this library.
+ */
+extern void
+xen_host_metrics_record_free(xen_host_metrics_record *record);
+
+
+typedef struct xen_host_metrics_record_opt
+{
+ bool is_record;
+ union
+ {
+ xen_host_metrics handle;
+ xen_host_metrics_record *record;
+ } u;
+} xen_host_metrics_record_opt;
+
+/**
+ * Allocate a xen_host_metrics_record_opt.
+ */
+extern xen_host_metrics_record_opt *
+xen_host_metrics_record_opt_alloc(void);
+
+/**
+ * Free the given xen_host_metrics_record_opt, and all referenced
+ * values. The given record_opt must have been allocated by this library.
+ */
+extern void
+xen_host_metrics_record_opt_free(xen_host_metrics_record_opt *record_opt);
+
+
+typedef struct xen_host_metrics_record_set
+{
+ size_t size;
+ xen_host_metrics_record *contents[];
+} xen_host_metrics_record_set;
+
+/**
+ * Allocate a xen_host_metrics_record_set of the given size.
+ */
+extern xen_host_metrics_record_set *
+xen_host_metrics_record_set_alloc(size_t size);
+
+/**
+ * Free the given xen_host_metrics_record_set, and all referenced
+ * values. The given set must have been allocated by this library.
+ */
+extern void
+xen_host_metrics_record_set_free(xen_host_metrics_record_set *set);
+
+
+
+typedef struct xen_host_metrics_record_opt_set
+{
+ size_t size;
+ xen_host_metrics_record_opt *contents[];
+} xen_host_metrics_record_opt_set;
+
+/**
+ * Allocate a xen_host_metrics_record_opt_set of the given size.
+ */
+extern xen_host_metrics_record_opt_set *
+xen_host_metrics_record_opt_set_alloc(size_t size);
+
+/**
+ * Free the given xen_host_metrics_record_opt_set, and all referenced
+ * values. The given set must have been allocated by this library.
+ */
+extern void
+xen_host_metrics_record_opt_set_free(xen_host_metrics_record_opt_set *set);
+
+
+/**
+ * Get a record containing the current state of the given host_metrics.
+ */
+extern bool
+xen_host_metrics_get_record(xen_session *session, xen_host_metrics_record **result, xen_host_metrics host_metrics);
+
+
+/**
+ * Get a reference to the host_metrics instance with the specified
+ * UUID.
+ */
+extern bool
+xen_host_metrics_get_by_uuid(xen_session *session, xen_host_metrics *result, char *uuid);
+
+
+/**
+ * Get the uuid field of the given host_metrics.
+ */
+extern bool
+xen_host_metrics_get_uuid(xen_session *session, char **result, xen_host_metrics host_metrics);
+
+
+/**
+ * Get the host field of the given host_metrics.
+ */
+extern bool
+xen_host_metrics_get_host(xen_session *session, xen_host *result, xen_host_metrics host_metrics);
+
+
+/**
+ * Get the memory/total field of the given host_metrics.
+ */
+extern bool
+xen_host_metrics_get_memory_total(xen_session *session, int64_t *result, xen_host_metrics host_metrics);
+
+
+/**
+ * Get the memory/free field of the given host_metrics.
+ */
+extern bool
+xen_host_metrics_get_memory_free(xen_session *session, int64_t *result, xen_host_metrics host_metrics);
+
+
+#endif
diff --git a/tools/libxen/include/xen_driver_type_internal.h b/tools/libxen/include/xen_host_metrics_decl.h
index c44639f692..e9137160ed 100644
--- a/tools/libxen/include/xen_driver_type_internal.h
+++ b/tools/libxen/include/xen_host_metrics_decl.h
@@ -16,22 +16,15 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#ifndef XEN_HOST_METRICS_DECL_H
+#define XEN_HOST_METRICS_DECL_H
-/*
- * Declarations of the abstract types used during demarshalling of enum
- * xen_driver_type. Internal to this library -- do not use from outside.
- */
-
-
-#ifndef XEN_DRIVER_TYPE_INTERNAL_H
-#define XEN_DRIVER_TYPE_INTERNAL_H
-
-
-#include "xen_internal.h"
-
-
-extern const abstract_type xen_driver_type_abstract_type_;
-extern const abstract_type xen_driver_type_set_abstract_type_;
+typedef void *xen_host_metrics;
+struct xen_host_metrics_set;
+struct xen_host_metrics_record;
+struct xen_host_metrics_record_set;
+struct xen_host_metrics_record_opt;
+struct xen_host_metrics_record_opt_set;
#endif
diff --git a/tools/libxen/include/xen_pbd.h b/tools/libxen/include/xen_pbd.h
new file mode 100644
index 0000000000..6d0f6b449e
--- /dev/null
+++ b/tools/libxen/include/xen_pbd.h
@@ -0,0 +1,216 @@
+/*
+ * Copyright (c) 2006, XenSource Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef XEN_PBD_H
+#define XEN_PBD_H
+
+#include "xen_common.h"
+#include "xen_host_decl.h"
+#include "xen_pbd_decl.h"
+#include "xen_sr_decl.h"
+#include "xen_string_string_map.h"
+
+
+/*
+ * The PBD class.
+ *
+ * The physical block devices through which hosts access SRs.
+ */
+
+
+/**
+ * Free the given xen_pbd. The given handle must have been allocated
+ * by this library.
+ */
+extern void
+xen_pbd_free(xen_pbd pbd);
+
+
+typedef struct xen_pbd_set
+{
+ size_t size;
+ xen_pbd *contents[];
+} xen_pbd_set;
+
+/**
+ * Allocate a xen_pbd_set of the given size.
+ */
+extern xen_pbd_set *
+xen_pbd_set_alloc(size_t size);
+
+/**
+ * Free the given xen_pbd_set. The given set must have been allocated
+ * by this library.
+ */
+extern void
+xen_pbd_set_free(xen_pbd_set *set);
+
+
+typedef struct xen_pbd_record
+{
+ xen_pbd handle;
+ char *uuid;
+ struct xen_host_record_opt *host;
+ struct xen_sr_record_opt *sr;
+ xen_string_string_map *device_config;
+ bool currently_attached;
+} xen_pbd_record;
+
+/**
+ * Allocate a xen_pbd_record.
+ */
+extern xen_pbd_record *
+xen_pbd_record_alloc(void);
+
+/**
+ * Free the given xen_pbd_record, and all referenced values. The given
+ * record must have been allocated by this library.
+ */
+extern void
+xen_pbd_record_free(xen_pbd_record *record);
+
+
+typedef struct xen_pbd_record_opt
+{
+ bool is_record;
+ union
+ {
+ xen_pbd handle;
+ xen_pbd_record *record;
+ } u;
+} xen_pbd_record_opt;
+
+/**
+ * Allocate a xen_pbd_record_opt.
+ */
+extern xen_pbd_record_opt *
+xen_pbd_record_opt_alloc(void);
+
+/**
+ * Free the given xen_pbd_record_opt, and all referenced values. The
+ * given record_opt must have been allocated by this library.
+ */
+extern void
+xen_pbd_record_opt_free(xen_pbd_record_opt *record_opt);
+
+
+typedef struct xen_pbd_record_set
+{
+ size_t size;
+ xen_pbd_record *contents[];
+} xen_pbd_record_set;
+
+/**
+ * Allocate a xen_pbd_record_set of the given size.
+ */
+extern xen_pbd_record_set *
+xen_pbd_record_set_alloc(size_t size);
+
+/**
+ * Free the given xen_pbd_record_set, and all referenced values. The
+ * given set must have been allocated by this library.
+ */
+extern void
+xen_pbd_record_set_free(xen_pbd_record_set *set);
+
+
+
+typedef struct xen_pbd_record_opt_set
+{
+ size_t size;
+ xen_pbd_record_opt *contents[];
+} xen_pbd_record_opt_set;
+
+/**
+ * Allocate a xen_pbd_record_opt_set of the given size.
+ */
+extern xen_pbd_record_opt_set *
+xen_pbd_record_opt_set_alloc(size_t size);
+
+/**
+ * Free the given xen_pbd_record_opt_set, and all referenced values.
+ * The given set must have been allocated by this library.
+ */
+extern void
+xen_pbd_record_opt_set_free(xen_pbd_record_opt_set *set);
+
+
+/**
+ * Get a record containing the current state of the given PBD.
+ */
+extern bool
+xen_pbd_get_record(xen_session *session, xen_pbd_record **result, xen_pbd pbd);
+
+
+/**
+ * Get a reference to the PBD instance with the specified UUID.
+ */
+extern bool
+xen_pbd_get_by_uuid(xen_session *session, xen_pbd *result, char *uuid);
+
+
+/**
+ * Create a new PBD instance, and return its handle.
+ */
+extern bool
+xen_pbd_create(xen_session *session, xen_pbd *result, xen_pbd_record *record);
+
+
+/**
+ * Destroy the specified PBD instance.
+ */
+extern bool
+xen_pbd_destroy(xen_session *session, xen_pbd pbd);
+
+
+/**
+ * Get the uuid field of the given PBD.
+ */
+extern bool
+xen_pbd_get_uuid(xen_session *session, char **result, xen_pbd pbd);
+
+
+/**
+ * Get the host field of the given PBD.
+ */
+extern bool
+xen_pbd_get_host(xen_session *session, xen_host *result, xen_pbd pbd);
+
+
+/**
+ * Get the SR field of the given PBD.
+ */
+extern bool
+xen_pbd_get_sr(xen_session *session, xen_sr *result, xen_pbd pbd);
+
+
+/**
+ * Get the device_config field of the given PBD.
+ */
+extern bool
+xen_pbd_get_device_config(xen_session *session, xen_string_string_map **result, xen_pbd pbd);
+
+
+/**
+ * Get the currently_attached field of the given PBD.
+ */
+extern bool
+xen_pbd_get_currently_attached(xen_session *session, bool *result, xen_pbd pbd);
+
+
+#endif
diff --git a/tools/libxen/include/xen_pbd_decl.h b/tools/libxen/include/xen_pbd_decl.h
new file mode 100644
index 0000000000..81f8f4b300
--- /dev/null
+++ b/tools/libxen/include/xen_pbd_decl.h
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2006, XenSource Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef XEN_PBD_DECL_H
+#define XEN_PBD_DECL_H
+
+typedef void *xen_pbd;
+
+struct xen_pbd_set;
+struct xen_pbd_record;
+struct xen_pbd_record_set;
+struct xen_pbd_record_opt;
+struct xen_pbd_record_opt_set;
+
+#endif
diff --git a/tools/libxen/include/xen_pif.h b/tools/libxen/include/xen_pif.h
index edc2b5a83b..a4d6db7420 100644
--- a/tools/libxen/include/xen_pif.h
+++ b/tools/libxen/include/xen_pif.h
@@ -23,11 +23,12 @@
#include "xen_host_decl.h"
#include "xen_network_decl.h"
#include "xen_pif_decl.h"
+#include "xen_pif_metrics_decl.h"
/*
- * The PIF class.
- *
+ * The PIF class.
+ *
* A physical network interface (note separate VLANs are represented as
* several PIFs).
*/
@@ -65,14 +66,13 @@ typedef struct xen_pif_record
{
xen_pif handle;
char *uuid;
- char *name;
+ char *device;
struct xen_network_record_opt *network;
struct xen_host_record_opt *host;
char *mac;
int64_t mtu;
- char *vlan;
- double io_read_kbs;
- double io_write_kbs;
+ int64_t vlan;
+ struct xen_pif_metrics_record_opt *metrics;
} xen_pif_record;
/**
@@ -169,20 +169,6 @@ xen_pif_get_by_uuid(xen_session *session, xen_pif *result, char *uuid);
/**
- * Create a new PIF instance, and return its handle.
- */
-extern bool
-xen_pif_create(xen_session *session, xen_pif *result, xen_pif_record *record);
-
-
-/**
- * Destroy the specified PIF instance.
- */
-extern bool
-xen_pif_destroy(xen_session *session, xen_pif pif);
-
-
-/**
* Get the uuid field of the given PIF.
*/
extern bool
@@ -190,10 +176,10 @@ xen_pif_get_uuid(xen_session *session, char **result, xen_pif pif);
/**
- * Get the name field of the given PIF.
+ * Get the device field of the given PIF.
*/
extern bool
-xen_pif_get_name(xen_session *session, char **result, xen_pif pif);
+xen_pif_get_device(xen_session *session, char **result, xen_pif pif);
/**
@@ -228,63 +214,57 @@ xen_pif_get_mtu(xen_session *session, int64_t *result, xen_pif pif);
* Get the VLAN field of the given PIF.
*/
extern bool
-xen_pif_get_vlan(xen_session *session, char **result, xen_pif pif);
+xen_pif_get_vlan(xen_session *session, int64_t *result, xen_pif pif);
/**
- * Get the io/read_kbs field of the given PIF.
+ * Get the metrics field of the given PIF.
*/
extern bool
-xen_pif_get_io_read_kbs(xen_session *session, double *result, xen_pif pif);
+xen_pif_get_metrics(xen_session *session, xen_pif_metrics *result, xen_pif pif);
/**
- * Get the io/write_kbs field of the given PIF.
+ * Set the device field of the given PIF.
*/
extern bool
-xen_pif_get_io_write_kbs(xen_session *session, double *result, xen_pif pif);
+xen_pif_set_device(xen_session *session, xen_pif pif, char *device);
/**
- * Set the name field of the given PIF.
- */
-extern bool
-xen_pif_set_name(xen_session *session, xen_pif pif, char *name);
-
-
-/**
- * Set the network field of the given PIF.
+ * Set the MAC field of the given PIF.
*/
extern bool
-xen_pif_set_network(xen_session *session, xen_pif pif, xen_network network);
+xen_pif_set_mac(xen_session *session, xen_pif pif, char *mac);
/**
- * Set the host field of the given PIF.
+ * Set the MTU field of the given PIF.
*/
extern bool
-xen_pif_set_host(xen_session *session, xen_pif pif, xen_host host);
+xen_pif_set_mtu(xen_session *session, xen_pif pif, int64_t mtu);
/**
- * Set the MAC field of the given PIF.
+ * Set the VLAN field of the given PIF.
*/
extern bool
-xen_pif_set_mac(xen_session *session, xen_pif pif, char *mac);
+xen_pif_set_vlan(xen_session *session, xen_pif pif, int64_t vlan);
/**
- * Set the MTU field of the given PIF.
+ * Create a VLAN interface from an existing physical interface
*/
extern bool
-xen_pif_set_mtu(xen_session *session, xen_pif pif, int64_t mtu);
+xen_pif_create_vlan(xen_session *session, xen_pif *result, char *device, xen_network network, xen_host host, int64_t vlan);
/**
- * Set the VLAN field of the given PIF.
+ * Destroy the interface (provided it is a synthetic interface like a
+ * VLAN; fail if it is a physical interface)
*/
extern bool
-xen_pif_set_vlan(xen_session *session, xen_pif pif, char *vlan);
+xen_pif_destroy(xen_session *session, xen_pif self);
#endif
diff --git a/tools/libxen/include/xen_pif_metrics.h b/tools/libxen/include/xen_pif_metrics.h
new file mode 100644
index 0000000000..420516d8b6
--- /dev/null
+++ b/tools/libxen/include/xen_pif_metrics.h
@@ -0,0 +1,192 @@
+/*
+ * Copyright (c) 2006, XenSource Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef XEN_PIF_METRICS_H
+#define XEN_PIF_METRICS_H
+
+#include "xen_common.h"
+#include "xen_pif_decl.h"
+#include "xen_pif_metrics_decl.h"
+
+
+/*
+ * The PIF_metrics class.
+ *
+ * The metrics associated with a physical network interface.
+ */
+
+
+/**
+ * Free the given xen_pif_metrics. The given handle must have been
+ * allocated by this library.
+ */
+extern void
+xen_pif_metrics_free(xen_pif_metrics pif_metrics);
+
+
+typedef struct xen_pif_metrics_set
+{
+ size_t size;
+ xen_pif_metrics *contents[];
+} xen_pif_metrics_set;
+
+/**
+ * Allocate a xen_pif_metrics_set of the given size.
+ */
+extern xen_pif_metrics_set *
+xen_pif_metrics_set_alloc(size_t size);
+
+/**
+ * Free the given xen_pif_metrics_set. The given set must have been
+ * allocated by this library.
+ */
+extern void
+xen_pif_metrics_set_free(xen_pif_metrics_set *set);
+
+
+typedef struct xen_pif_metrics_record
+{
+ xen_pif_metrics handle;
+ char *uuid;
+ struct xen_pif_record_opt *pif;
+ double io_read_kbs;
+ double io_write_kbs;
+} xen_pif_metrics_record;
+
+/**
+ * Allocate a xen_pif_metrics_record.
+ */
+extern xen_pif_metrics_record *
+xen_pif_metrics_record_alloc(void);
+
+/**
+ * Free the given xen_pif_metrics_record, and all referenced values.
+ * The given record must have been allocated by this library.
+ */
+extern void
+xen_pif_metrics_record_free(xen_pif_metrics_record *record);
+
+
+typedef struct xen_pif_metrics_record_opt
+{
+ bool is_record;
+ union
+ {
+ xen_pif_metrics handle;
+ xen_pif_metrics_record *record;
+ } u;
+} xen_pif_metrics_record_opt;
+
+/**
+ * Allocate a xen_pif_metrics_record_opt.
+ */
+extern xen_pif_metrics_record_opt *
+xen_pif_metrics_record_opt_alloc(void);
+
+/**
+ * Free the given xen_pif_metrics_record_opt, and all referenced
+ * values. The given record_opt must have been allocated by this library.
+ */
+extern void
+xen_pif_metrics_record_opt_free(xen_pif_metrics_record_opt *record_opt);
+
+
+typedef struct xen_pif_metrics_record_set
+{
+ size_t size;
+ xen_pif_metrics_record *contents[];
+} xen_pif_metrics_record_set;
+
+/**
+ * Allocate a xen_pif_metrics_record_set of the given size.
+ */
+extern xen_pif_metrics_record_set *
+xen_pif_metrics_record_set_alloc(size_t size);
+
+/**
+ * Free the given xen_pif_metrics_record_set, and all referenced
+ * values. The given set must have been allocated by this library.
+ */
+extern void
+xen_pif_metrics_record_set_free(xen_pif_metrics_record_set *set);
+
+
+
+typedef struct xen_pif_metrics_record_opt_set
+{
+ size_t size;
+ xen_pif_metrics_record_opt *contents[];
+} xen_pif_metrics_record_opt_set;
+
+/**
+ * Allocate a xen_pif_metrics_record_opt_set of the given size.
+ */
+extern xen_pif_metrics_record_opt_set *
+xen_pif_metrics_record_opt_set_alloc(size_t size);
+
+/**
+ * Free the given xen_pif_metrics_record_opt_set, and all referenced
+ * values. The given set must have been allocated by this library.
+ */
+extern void
+xen_pif_metrics_record_opt_set_free(xen_pif_metrics_record_opt_set *set);
+
+
+/**
+ * Get a record containing the current state of the given PIF_metrics.
+ */
+extern bool
+xen_pif_metrics_get_record(xen_session *session, xen_pif_metrics_record **result, xen_pif_metrics pif_metrics);
+
+
+/**
+ * Get a reference to the PIF_metrics instance with the specified UUID.
+ */
+extern bool
+xen_pif_metrics_get_by_uuid(xen_session *session, xen_pif_metrics *result, char *uuid);
+
+
+/**
+ * Get the uuid field of the given PIF_metrics.
+ */
+extern bool
+xen_pif_metrics_get_uuid(xen_session *session, char **result, xen_pif_metrics pif_metrics);
+
+
+/**
+ * Get the PIF field of the given PIF_metrics.
+ */
+extern bool
+xen_pif_metrics_get_pif(xen_session *session, xen_pif *result, xen_pif_metrics pif_metrics);
+
+
+/**
+ * Get the io/read_kbs field of the given PIF_metrics.
+ */
+extern bool
+xen_pif_metrics_get_io_read_kbs(xen_session *session, double *result, xen_pif_metrics pif_metrics);
+
+
+/**
+ * Get the io/write_kbs field of the given PIF_metrics.
+ */
+extern bool
+xen_pif_metrics_get_io_write_kbs(xen_session *session, double *result, xen_pif_metrics pif_metrics);
+
+
+#endif
diff --git a/tools/libxen/include/xen_pif_metrics_decl.h b/tools/libxen/include/xen_pif_metrics_decl.h
new file mode 100644
index 0000000000..71afe69d53
--- /dev/null
+++ b/tools/libxen/include/xen_pif_metrics_decl.h
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2006, XenSource Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef XEN_PIF_METRICS_DECL_H
+#define XEN_PIF_METRICS_DECL_H
+
+typedef void *xen_pif_metrics;
+
+struct xen_pif_metrics_set;
+struct xen_pif_metrics_record;
+struct xen_pif_metrics_record_set;
+struct xen_pif_metrics_record_opt;
+struct xen_pif_metrics_record_opt_set;
+
+#endif
diff --git a/tools/libxen/include/xen_sr.h b/tools/libxen/include/xen_sr.h
index eb8a420149..e5e4299844 100644
--- a/tools/libxen/include/xen_sr.h
+++ b/tools/libxen/include/xen_sr.h
@@ -20,13 +20,14 @@
#define XEN_SR_H
#include "xen_common.h"
+#include "xen_pbd_decl.h"
#include "xen_sr_decl.h"
#include "xen_vdi_decl.h"
/*
- * The SR class.
- *
+ * The SR class.
+ *
* A storage repository.
*/
@@ -66,6 +67,7 @@ typedef struct xen_sr_record
char *name_label;
char *name_description;
struct xen_vdi_record_opt_set *vdis;
+ struct xen_pbd_record_opt_set *pbds;
int64_t virtual_allocation;
int64_t physical_utilisation;
int64_t physical_size;
@@ -216,6 +218,13 @@ xen_sr_get_vdis(xen_session *session, struct xen_vdi_set **result, xen_sr sr);
/**
+ * Get the PBDs field of the given SR.
+ */
+extern bool
+xen_sr_get_pbds(xen_session *session, struct xen_pbd_set **result, xen_sr sr);
+
+
+/**
* Get the virtual_allocation field of the given SR.
*/
extern bool
diff --git a/tools/libxen/include/xen_vbd.h b/tools/libxen/include/xen_vbd.h
index 2b9d8b05eb..880449f3c1 100644
--- a/tools/libxen/include/xen_vbd.h
+++ b/tools/libxen/include/xen_vbd.h
@@ -20,7 +20,6 @@
#define XEN_VBD_H
#include "xen_common.h"
-#include "xen_driver_type.h"
#include "xen_vbd_decl.h"
#include "xen_vbd_mode.h"
#include "xen_vdi_decl.h"
@@ -28,8 +27,8 @@
/*
- * The VBD class.
- *
+ * The VBD class.
+ *
* A virtual block device.
*/
@@ -70,8 +69,8 @@ typedef struct xen_vbd_record
struct xen_vdi_record_opt *vdi;
char *device;
char *image;
+ bool bootable;
enum xen_vbd_mode mode;
- enum xen_driver_type driver;
double io_read_kbs;
double io_write_kbs;
} xen_vbd_record;
@@ -212,17 +211,17 @@ xen_vbd_get_device(xen_session *session, char **result, xen_vbd vbd);
/**
- * Get the mode field of the given VBD.
+ * Get the bootable field of the given VBD.
*/
extern bool
-xen_vbd_get_mode(xen_session *session, enum xen_vbd_mode *result, xen_vbd vbd);
+xen_vbd_get_bootable(xen_session *session, bool *result, xen_vbd vbd);
/**
- * Get the driver field of the given VBD.
+ * Get the mode field of the given VBD.
*/
extern bool
-xen_vbd_get_driver(xen_session *session, enum xen_driver_type *result, xen_vbd vbd);
+xen_vbd_get_mode(xen_session *session, enum xen_vbd_mode *result, xen_vbd vbd);
/**
@@ -240,20 +239,6 @@ xen_vbd_get_io_write_kbs(xen_session *session, double *result, xen_vbd vbd);
/**
- * Set the VM field of the given VBD.
- */
-extern bool
-xen_vbd_set_vm(xen_session *session, xen_vbd vbd, xen_vm vm);
-
-
-/**
- * Set the VDI field of the given VBD.
- */
-extern bool
-xen_vbd_set_vdi(xen_session *session, xen_vbd vbd, xen_vdi vdi);
-
-
-/**
* Set the device field of the given VBD.
*/
extern bool
@@ -261,17 +246,17 @@ xen_vbd_set_device(xen_session *session, xen_vbd vbd, char *device);
/**
- * Set the mode field of the given VBD.
+ * Set the bootable field of the given VBD.
*/
extern bool
-xen_vbd_set_mode(xen_session *session, xen_vbd vbd, enum xen_vbd_mode mode);
+xen_vbd_set_bootable(xen_session *session, xen_vbd vbd, bool bootable);
/**
- * Set the driver field of the given VBD.
+ * Set the mode field of the given VBD.
*/
extern bool
-xen_vbd_set_driver(xen_session *session, xen_vbd vbd, enum xen_driver_type driver);
+xen_vbd_set_mode(xen_session *session, xen_vbd vbd, enum xen_vbd_mode mode);
/**
diff --git a/tools/libxen/include/xen_vdi.h b/tools/libxen/include/xen_vdi.h
index cfdbc6a61c..d72eceb001 100644
--- a/tools/libxen/include/xen_vdi.h
+++ b/tools/libxen/include/xen_vdi.h
@@ -20,6 +20,7 @@
#define XEN_VDI_H
#include "xen_common.h"
+#include "xen_crashdump_decl.h"
#include "xen_sr_decl.h"
#include "xen_vbd_decl.h"
#include "xen_vdi_decl.h"
@@ -27,8 +28,8 @@
/*
- * The VDI class.
- *
+ * The VDI class.
+ *
* A virtual disk image.
*/
@@ -69,12 +70,11 @@ typedef struct xen_vdi_record
char *name_description;
struct xen_sr_record_opt *sr;
struct xen_vbd_record_opt_set *vbds;
+ struct xen_crashdump_record_opt_set *crash_dumps;
int64_t virtual_size;
int64_t physical_utilisation;
int64_t sector_size;
enum xen_vdi_type type;
- struct xen_vdi_record_opt *parent;
- struct xen_vdi_record_opt_set *children;
bool sharable;
bool read_only;
} xen_vdi_record;
@@ -229,6 +229,13 @@ xen_vdi_get_vbds(xen_session *session, struct xen_vbd_set **result, xen_vdi vdi)
/**
+ * Get the crash_dumps field of the given VDI.
+ */
+extern bool
+xen_vdi_get_crash_dumps(xen_session *session, struct xen_crashdump_set **result, xen_vdi vdi);
+
+
+/**
* Get the virtual_size field of the given VDI.
*/
extern bool
@@ -257,20 +264,6 @@ xen_vdi_get_type(xen_session *session, enum xen_vdi_type *result, xen_vdi vdi);
/**
- * Get the parent field of the given VDI.
- */
-extern bool
-xen_vdi_get_parent(xen_session *session, xen_vdi *result, xen_vdi vdi);
-
-
-/**
- * Get the children field of the given VDI.
- */
-extern bool
-xen_vdi_get_children(xen_session *session, struct xen_vdi_set **result, xen_vdi vdi);
-
-
-/**
* Get the sharable field of the given VDI.
*/
extern bool
diff --git a/tools/libxen/include/xen_vdi_type.h b/tools/libxen/include/xen_vdi_type.h
index 33ba7c61bf..01168491ee 100644
--- a/tools/libxen/include/xen_vdi_type.h
+++ b/tools/libxen/include/xen_vdi_type.h
@@ -38,7 +38,17 @@ enum xen_vdi_type
/**
* a disk that may be reformatted on upgrade
*/
- XEN_VDI_TYPE_EPHEMERAL
+ XEN_VDI_TYPE_EPHEMERAL,
+
+ /**
+ * a disk that stores a suspend image
+ */
+ XEN_VDI_TYPE_SUSPEND,
+
+ /**
+ * a disk that stores VM crashdump information
+ */
+ XEN_VDI_TYPE_CRASHDUMP
};
diff --git a/tools/libxen/include/xen_vif.h b/tools/libxen/include/xen_vif.h
index 4efc3f0851..7141bf3197 100644
--- a/tools/libxen/include/xen_vif.h
+++ b/tools/libxen/include/xen_vif.h
@@ -20,15 +20,14 @@
#define XEN_VIF_H
#include "xen_common.h"
-#include "xen_driver_type.h"
#include "xen_network_decl.h"
#include "xen_vif_decl.h"
#include "xen_vm_decl.h"
/*
- * The VIF class.
- *
+ * The VIF class.
+ *
* A virtual network interface.
*/
@@ -65,8 +64,6 @@ typedef struct xen_vif_record
{
xen_vif handle;
char *uuid;
- char *name;
- enum xen_driver_type type;
char *device;
struct xen_network_record_opt *network;
struct xen_vm_record_opt *vm;
@@ -191,20 +188,6 @@ xen_vif_get_uuid(xen_session *session, char **result, xen_vif vif);
/**
- * Get the name field of the given VIF.
- */
-extern bool
-xen_vif_get_name(xen_session *session, char **result, xen_vif vif);
-
-
-/**
- * Get the type field of the given VIF.
- */
-extern bool
-xen_vif_get_type(xen_session *session, enum xen_driver_type *result, xen_vif vif);
-
-
-/**
* Get the device field of the given VIF.
*/
extern bool
@@ -254,20 +237,6 @@ xen_vif_get_io_write_kbs(xen_session *session, double *result, xen_vif vif);
/**
- * Set the name field of the given VIF.
- */
-extern bool
-xen_vif_set_name(xen_session *session, xen_vif vif, char *name);
-
-
-/**
- * Set the type field of the given VIF.
- */
-extern bool
-xen_vif_set_type(xen_session *session, xen_vif vif, enum xen_driver_type type);
-
-
-/**
* Set the device field of the given VIF.
*/
extern bool
@@ -275,20 +244,6 @@ xen_vif_set_device(xen_session *session, xen_vif vif, char *device);
/**
- * Set the network field of the given VIF.
- */
-extern bool
-xen_vif_set_network(xen_session *session, xen_vif vif, xen_network network);
-
-
-/**
- * Set the VM field of the given VIF.
- */
-extern bool
-xen_vif_set_vm(xen_session *session, xen_vif vif, xen_vm vm);
-
-
-/**
* Set the MAC field of the given VIF.
*/
extern bool
diff --git a/tools/libxen/include/xen_vm.h b/tools/libxen/include/xen_vm.h
index 5287be5873..7a56ba482e 100644
--- a/tools/libxen/include/xen_vm.h
+++ b/tools/libxen/include/xen_vm.h
@@ -21,15 +21,17 @@
#include "xen_common.h"
#include "xen_console_decl.h"
-#include "xen_cpu_feature.h"
+#include "xen_crashdump_decl.h"
#include "xen_host_decl.h"
#include "xen_int_float_map.h"
#include "xen_on_crash_behaviour.h"
#include "xen_on_normal_exit.h"
#include "xen_string_string_map.h"
#include "xen_vbd_decl.h"
+#include "xen_vdi_decl.h"
#include "xen_vif_decl.h"
#include "xen_vm_decl.h"
+#include "xen_vm_metrics_decl.h"
#include "xen_vm_power_state.h"
#include "xen_vtpm_decl.h"
@@ -51,7 +53,10 @@
* PV/ramdisk, PV/args and PV/bootloader_args will be passed to the bootloader
* unmodified, and interpretation of those fields is then specific to the
* bootloader itself, including the possibility that the bootloader will
- * ignore some or all of those given values.
+ * ignore some or all of those given values. Finally the paths of all bootable
+ * disks are added to the bootloader commandline (a disk is bootable if its
+ * VBD has the bootable flag set). There may be zero, one or many bootable
+ * disks; the bootloader decides which disk (if any) to boot from.
*
* If the bootloader is pygrub, then the menu.lst is parsed if present in the
* guest's filesystem, otherwise the specified kernel and ramdisk are used, or
@@ -106,27 +111,25 @@ typedef struct xen_vm_record
int64_t user_version;
bool is_a_template;
bool auto_power_on;
+ struct xen_vdi_record_opt *suspend_vdi;
struct xen_host_record_opt *resident_on;
int64_t memory_static_max;
int64_t memory_dynamic_max;
- int64_t memory_actual;
int64_t memory_dynamic_min;
int64_t memory_static_min;
char *vcpus_policy;
- char *vcpus_params;
+ xen_string_string_map *vcpus_params;
+ int64_t vcpus_max;
+ int64_t vcpus_at_startup;
int64_t vcpus_number;
xen_int_float_map *vcpus_utilisation;
- struct xen_cpu_feature_set *vcpus_features_required;
- struct xen_cpu_feature_set *vcpus_features_can_use;
- struct xen_cpu_feature_set *vcpus_features_force_on;
- struct xen_cpu_feature_set *vcpus_features_force_off;
enum xen_on_normal_exit actions_after_shutdown;
enum xen_on_normal_exit actions_after_reboot;
- enum xen_on_normal_exit actions_after_suspend;
enum xen_on_crash_behaviour actions_after_crash;
struct xen_console_record_opt_set *consoles;
struct xen_vif_record_opt_set *vifs;
struct xen_vbd_record_opt_set *vbds;
+ struct xen_crashdump_record_opt_set *crash_dumps;
struct xen_vtpm_record_opt_set *vtpms;
char *pv_bootloader;
char *pv_kernel;
@@ -141,7 +144,9 @@ typedef struct xen_vm_record
bool platform_enable_audio;
char *pci_bus;
xen_string_string_map *tools_version;
- xen_string_string_map *otherconfig;
+ xen_string_string_map *other_config;
+ bool is_control_domain;
+ struct xen_vm_metrics_record_opt *metrics;
} xen_vm_record;
/**
@@ -310,6 +315,13 @@ xen_vm_get_auto_power_on(xen_session *session, bool *result, xen_vm vm);
/**
+ * Get the suspend_VDI field of the given VM.
+ */
+extern bool
+xen_vm_get_suspend_vdi(xen_session *session, xen_vdi *result, xen_vm vm);
+
+
+/**
* Get the resident_on field of the given VM.
*/
extern bool
@@ -331,13 +343,6 @@ xen_vm_get_memory_dynamic_max(xen_session *session, int64_t *result, xen_vm vm);
/**
- * Get the memory/actual field of the given VM.
- */
-extern bool
-xen_vm_get_memory_actual(xen_session *session, int64_t *result, xen_vm vm);
-
-
-/**
* Get the memory/dynamic_min field of the given VM.
*/
extern bool
@@ -362,49 +367,35 @@ xen_vm_get_vcpus_policy(xen_session *session, char **result, xen_vm vm);
* Get the VCPUs/params field of the given VM.
*/
extern bool
-xen_vm_get_vcpus_params(xen_session *session, char **result, xen_vm vm);
-
-
-/**
- * Get the VCPUs/number field of the given VM.
- */
-extern bool
-xen_vm_get_vcpus_number(xen_session *session, int64_t *result, xen_vm vm);
-
-
-/**
- * Get the VCPUs/utilisation field of the given VM.
- */
-extern bool
-xen_vm_get_vcpus_utilisation(xen_session *session, xen_int_float_map **result, xen_vm vm);
+xen_vm_get_vcpus_params(xen_session *session, xen_string_string_map **result, xen_vm vm);
/**
- * Get the VCPUs/features/required field of the given VM.
+ * Get the VCPUs/max field of the given VM.
*/
extern bool
-xen_vm_get_vcpus_features_required(xen_session *session, struct xen_cpu_feature_set **result, xen_vm vm);
+xen_vm_get_vcpus_max(xen_session *session, int64_t *result, xen_vm vm);
/**
- * Get the VCPUs/features/can_use field of the given VM.
+ * Get the VCPUs/at_startup field of the given VM.
*/
extern bool
-xen_vm_get_vcpus_features_can_use(xen_session *session, struct xen_cpu_feature_set **result, xen_vm vm);
+xen_vm_get_vcpus_at_startup(xen_session *session, int64_t *result, xen_vm vm);
/**
- * Get the VCPUs/features/force_on field of the given VM.
+ * Get the VCPUs/number field of the given VM.
*/
extern bool
-xen_vm_get_vcpus_features_force_on(xen_session *session, struct xen_cpu_feature_set **result, xen_vm vm);
+xen_vm_get_vcpus_number(xen_session *session, int64_t *result, xen_vm vm);
/**
- * Get the VCPUs/features/force_off field of the given VM.
+ * Get the VCPUs/utilisation field of the given VM.
*/
extern bool
-xen_vm_get_vcpus_features_force_off(xen_session *session, struct xen_cpu_feature_set **result, xen_vm vm);
+xen_vm_get_vcpus_utilisation(xen_session *session, xen_int_float_map **result, xen_vm vm);
/**
@@ -422,13 +413,6 @@ xen_vm_get_actions_after_reboot(xen_session *session, enum xen_on_normal_exit *r
/**
- * Get the actions/after_suspend field of the given VM.
- */
-extern bool
-xen_vm_get_actions_after_suspend(xen_session *session, enum xen_on_normal_exit *result, xen_vm vm);
-
-
-/**
* Get the actions/after_crash field of the given VM.
*/
extern bool
@@ -457,6 +441,13 @@ xen_vm_get_vbds(xen_session *session, struct xen_vbd_set **result, xen_vm vm);
/**
+ * Get the crash_dumps field of the given VM.
+ */
+extern bool
+xen_vm_get_crash_dumps(xen_session *session, struct xen_crashdump_set **result, xen_vm vm);
+
+
+/**
* Get the VTPMs field of the given VM.
*/
extern bool
@@ -555,10 +546,24 @@ xen_vm_get_tools_version(xen_session *session, xen_string_string_map **result, x
/**
- * Get the otherConfig field of the given VM.
+ * Get the other_config field of the given VM.
+ */
+extern bool
+xen_vm_get_other_config(xen_session *session, xen_string_string_map **result, xen_vm vm);
+
+
+/**
+ * Get the is_control_domain field of the given VM.
+ */
+extern bool
+xen_vm_get_is_control_domain(xen_session *session, bool *result, xen_vm vm);
+
+
+/**
+ * Get the metrics field of the given VM.
*/
extern bool
-xen_vm_get_otherconfig(xen_session *session, xen_string_string_map **result, xen_vm vm);
+xen_vm_get_metrics(xen_session *session, xen_vm_metrics *result, xen_vm vm);
/**
@@ -597,84 +602,76 @@ xen_vm_set_auto_power_on(xen_session *session, xen_vm vm, bool auto_power_on);
/**
- * Set the memory/dynamic_max field of the given VM.
+ * Set the memory/static_max field of the given VM.
*/
extern bool
-xen_vm_set_memory_dynamic_max(xen_session *session, xen_vm vm, int64_t dynamic_max);
+xen_vm_set_memory_static_max(xen_session *session, xen_vm vm, int64_t static_max);
/**
- * Set the memory/dynamic_min field of the given VM.
- */
-extern bool
-xen_vm_set_memory_dynamic_min(xen_session *session, xen_vm vm, int64_t dynamic_min);
-
-
-/**
- * Set the VCPUs/policy field of the given VM.
+ * Set the memory/dynamic_max field of the given VM.
*/
extern bool
-xen_vm_set_vcpus_policy(xen_session *session, xen_vm vm, char *policy);
+xen_vm_set_memory_dynamic_max(xen_session *session, xen_vm vm, int64_t dynamic_max);
/**
- * Set the VCPUs/params field of the given VM.
+ * Set the memory/dynamic_min field of the given VM.
*/
extern bool
-xen_vm_set_vcpus_params(xen_session *session, xen_vm vm, char *params);
+xen_vm_set_memory_dynamic_min(xen_session *session, xen_vm vm, int64_t dynamic_min);
/**
- * Set the VCPUs/number field of the given VM.
+ * Set the memory/static_min field of the given VM.
*/
extern bool
-xen_vm_set_vcpus_number(xen_session *session, xen_vm vm, int64_t number);
+xen_vm_set_memory_static_min(xen_session *session, xen_vm vm, int64_t static_min);
/**
- * Set the VCPUs/features/force_on field of the given VM.
+ * Set the VCPUs/policy field of the given VM.
*/
extern bool
-xen_vm_set_vcpus_features_force_on(xen_session *session, xen_vm vm, struct xen_cpu_feature_set *force_on);
+xen_vm_set_vcpus_policy(xen_session *session, xen_vm vm, char *policy);
/**
- * Add the given value to the VCPUs/features/force_on field of the
- * given VM. If the value is already in that Set, then do nothing.
+ * Set the VCPUs/params field of the given VM.
*/
extern bool
-xen_vm_add_vcpus_features_force_on(xen_session *session, xen_vm vm, enum xen_cpu_feature value);
+xen_vm_set_vcpus_params(xen_session *session, xen_vm vm, xen_string_string_map *params);
/**
- * Remove the given value from the VCPUs/features/force_on field of the
- * given VM. If the value is not in that Set, then do nothing.
+ * Add the given key-value pair to the VCPUs/params field of the given
+ * VM.
*/
extern bool
-xen_vm_remove_vcpus_features_force_on(xen_session *session, xen_vm vm, enum xen_cpu_feature value);
+xen_vm_add_to_vcpus_params(xen_session *session, xen_vm vm, char *key, char *value);
/**
- * Set the VCPUs/features/force_off field of the given VM.
+ * Remove the given key and its corresponding value from the
+ * VCPUs/params field of the given VM. If the key is not in that Map, then do
+ * nothing.
*/
extern bool
-xen_vm_set_vcpus_features_force_off(xen_session *session, xen_vm vm, struct xen_cpu_feature_set *force_off);
+xen_vm_remove_from_vcpus_params(xen_session *session, xen_vm vm, char *key);
/**
- * Add the given value to the VCPUs/features/force_off field of the
- * given VM. If the value is already in that Set, then do nothing.
+ * Set the VCPUs/max field of the given VM.
*/
extern bool
-xen_vm_add_vcpus_features_force_off(xen_session *session, xen_vm vm, enum xen_cpu_feature value);
+xen_vm_set_vcpus_max(xen_session *session, xen_vm vm, int64_t max);
/**
- * Remove the given value from the VCPUs/features/force_off field of
- * the given VM. If the value is not in that Set, then do nothing.
+ * Set the VCPUs/at_startup field of the given VM.
*/
extern bool
-xen_vm_remove_vcpus_features_force_off(xen_session *session, xen_vm vm, enum xen_cpu_feature value);
+xen_vm_set_vcpus_at_startup(xen_session *session, xen_vm vm, int64_t at_startup);
/**
@@ -692,13 +689,6 @@ xen_vm_set_actions_after_reboot(xen_session *session, xen_vm vm, enum xen_on_nor
/**
- * Set the actions/after_suspend field of the given VM.
- */
-extern bool
-xen_vm_set_actions_after_suspend(xen_session *session, xen_vm vm, enum xen_on_normal_exit after_suspend);
-
-
-/**
* Set the actions/after_crash field of the given VM.
*/
extern bool
@@ -783,10 +773,27 @@ xen_vm_set_platform_enable_audio(xen_session *session, xen_vm vm, bool enable_au
/**
- * Set the otherConfig field of the given VM.
+ * Set the other_config field of the given VM.
*/
extern bool
-xen_vm_set_otherconfig(xen_session *session, xen_vm vm, xen_string_string_map *otherconfig);
+xen_vm_set_other_config(xen_session *session, xen_vm vm, xen_string_string_map *other_config);
+
+
+/**
+ * Add the given key-value pair to the other_config field of the given
+ * VM.
+ */
+extern bool
+xen_vm_add_to_other_config(xen_session *session, xen_vm vm, char *key, char *value);
+
+
+/**
+ * Remove the given key and its corresponding value from the
+ * other_config field of the given VM. If the key is not in that Map, then do
+ * nothing.
+ */
+extern bool
+xen_vm_remove_from_other_config(xen_session *session, xen_vm vm, char *key);
/**
@@ -829,6 +836,8 @@ xen_vm_unpause(xen_session *session, xen_vm vm);
*
* Once shutdown has been completed perform poweroff action specified in guest
* configuration.
+ *
+ * This can only be called when the specified VM is in the Running state.
*/
extern bool
xen_vm_clean_shutdown(xen_session *session, xen_vm vm);
@@ -840,6 +849,8 @@ xen_vm_clean_shutdown(xen_session *session, xen_vm vm);
*
* Once shutdown has been completed perform reboot action specified in guest
* configuration.
+ *
+ * This can only be called when the specified VM is in the Running state.
*/
extern bool
xen_vm_clean_reboot(xen_session *session, xen_vm vm);
@@ -862,14 +873,16 @@ xen_vm_hard_reboot(xen_session *session, xen_vm vm);
/**
- * Suspend the specified VM to disk.
+ * Suspend the specified VM to disk. This can only be called when the
+ * specified VM is in the Running state.
*/
extern bool
xen_vm_suspend(xen_session *session, xen_vm vm);
/**
- * Awaken the specified VM and resume it.
+ * Awaken the specified VM and resume it. This can only be called when
+ * the specified VM is in the Suspended state.
*/
extern bool
xen_vm_resume(xen_session *session, xen_vm vm, bool start_paused);
diff --git a/tools/libxen/include/xen_vm_metrics.h b/tools/libxen/include/xen_vm_metrics.h
new file mode 100644
index 0000000000..740e327d10
--- /dev/null
+++ b/tools/libxen/include/xen_vm_metrics.h
@@ -0,0 +1,201 @@
+/*
+ * Copyright (c) 2006, XenSource Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef XEN_VM_METRICS_H
+#define XEN_VM_METRICS_H
+
+#include "xen_common.h"
+#include "xen_int_float_map.h"
+#include "xen_vm_decl.h"
+#include "xen_vm_metrics_decl.h"
+
+
+/*
+ * The VM_metrics class.
+ *
+ * The metrics associated with a VM.
+ */
+
+
+/**
+ * Free the given xen_vm_metrics. The given handle must have been
+ * allocated by this library.
+ */
+extern void
+xen_vm_metrics_free(xen_vm_metrics vm_metrics);
+
+
+typedef struct xen_vm_metrics_set
+{
+ size_t size;
+ xen_vm_metrics *contents[];
+} xen_vm_metrics_set;
+
+/**
+ * Allocate a xen_vm_metrics_set of the given size.
+ */
+extern xen_vm_metrics_set *
+xen_vm_metrics_set_alloc(size_t size);
+
+/**
+ * Free the given xen_vm_metrics_set. The given set must have been
+ * allocated by this library.
+ */
+extern void
+xen_vm_metrics_set_free(xen_vm_metrics_set *set);
+
+
+typedef struct xen_vm_metrics_record
+{
+ xen_vm_metrics handle;
+ char *uuid;
+ struct xen_vm_record_opt *vm;
+ int64_t memory_actual;
+ int64_t vcpus_number;
+ xen_int_float_map *vcpus_utilisation;
+} xen_vm_metrics_record;
+
+/**
+ * Allocate a xen_vm_metrics_record.
+ */
+extern xen_vm_metrics_record *
+xen_vm_metrics_record_alloc(void);
+
+/**
+ * Free the given xen_vm_metrics_record, and all referenced values.
+ * The given record must have been allocated by this library.
+ */
+extern void
+xen_vm_metrics_record_free(xen_vm_metrics_record *record);
+
+
+typedef struct xen_vm_metrics_record_opt
+{
+ bool is_record;
+ union
+ {
+ xen_vm_metrics handle;
+ xen_vm_metrics_record *record;
+ } u;
+} xen_vm_metrics_record_opt;
+
+/**
+ * Allocate a xen_vm_metrics_record_opt.
+ */
+extern xen_vm_metrics_record_opt *
+xen_vm_metrics_record_opt_alloc(void);
+
+/**
+ * Free the given xen_vm_metrics_record_opt, and all referenced values.
+ * The given record_opt must have been allocated by this library.
+ */
+extern void
+xen_vm_metrics_record_opt_free(xen_vm_metrics_record_opt *record_opt);
+
+
+typedef struct xen_vm_metrics_record_set
+{
+ size_t size;
+ xen_vm_metrics_record *contents[];
+} xen_vm_metrics_record_set;
+
+/**
+ * Allocate a xen_vm_metrics_record_set of the given size.
+ */
+extern xen_vm_metrics_record_set *
+xen_vm_metrics_record_set_alloc(size_t size);
+
+/**
+ * Free the given xen_vm_metrics_record_set, and all referenced values.
+ * The given set must have been allocated by this library.
+ */
+extern void
+xen_vm_metrics_record_set_free(xen_vm_metrics_record_set *set);
+
+
+
+typedef struct xen_vm_metrics_record_opt_set
+{
+ size_t size;
+ xen_vm_metrics_record_opt *contents[];
+} xen_vm_metrics_record_opt_set;
+
+/**
+ * Allocate a xen_vm_metrics_record_opt_set of the given size.
+ */
+extern xen_vm_metrics_record_opt_set *
+xen_vm_metrics_record_opt_set_alloc(size_t size);
+
+/**
+ * Free the given xen_vm_metrics_record_opt_set, and all referenced
+ * values. The given set must have been allocated by this library.
+ */
+extern void
+xen_vm_metrics_record_opt_set_free(xen_vm_metrics_record_opt_set *set);
+
+
+/**
+ * Get a record containing the current state of the given VM_metrics.
+ */
+extern bool
+xen_vm_metrics_get_record(xen_session *session, xen_vm_metrics_record **result, xen_vm_metrics vm_metrics);
+
+
+/**
+ * Get a reference to the VM_metrics instance with the specified UUID.
+ */
+extern bool
+xen_vm_metrics_get_by_uuid(xen_session *session, xen_vm_metrics *result, char *uuid);
+
+
+/**
+ * Get the uuid field of the given VM_metrics.
+ */
+extern bool
+xen_vm_metrics_get_uuid(xen_session *session, char **result, xen_vm_metrics vm_metrics);
+
+
+/**
+ * Get the VM field of the given VM_metrics.
+ */
+extern bool
+xen_vm_metrics_get_vm(xen_session *session, xen_vm *result, xen_vm_metrics vm_metrics);
+
+
+/**
+ * Get the memory/actual field of the given VM_metrics.
+ */
+extern bool
+xen_vm_metrics_get_memory_actual(xen_session *session, int64_t *result, xen_vm_metrics vm_metrics);
+
+
+/**
+ * Get the VCPUs/number field of the given VM_metrics.
+ */
+extern bool
+xen_vm_metrics_get_vcpus_number(xen_session *session, int64_t *result, xen_vm_metrics vm_metrics);
+
+
+/**
+ * Get the VCPUs/utilisation field of the given VM_metrics.
+ */
+extern bool
+xen_vm_metrics_get_vcpus_utilisation(xen_session *session, xen_int_float_map **result, xen_vm_metrics vm_metrics);
+
+
+#endif
diff --git a/tools/libxen/include/xen_vm_metrics_decl.h b/tools/libxen/include/xen_vm_metrics_decl.h
new file mode 100644
index 0000000000..ea1bcb51f7
--- /dev/null
+++ b/tools/libxen/include/xen_vm_metrics_decl.h
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2006, XenSource Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef XEN_VM_METRICS_DECL_H
+#define XEN_VM_METRICS_DECL_H
+
+typedef void *xen_vm_metrics;
+
+struct xen_vm_metrics_set;
+struct xen_vm_metrics_record;
+struct xen_vm_metrics_record_set;
+struct xen_vm_metrics_record_opt;
+struct xen_vm_metrics_record_opt_set;
+
+#endif
diff --git a/tools/libxen/include/xen_vtpm.h b/tools/libxen/include/xen_vtpm.h
index a04c8d4de3..add504221f 100644
--- a/tools/libxen/include/xen_vtpm.h
+++ b/tools/libxen/include/xen_vtpm.h
@@ -21,7 +21,6 @@
#define XEN_VTPM_H
#include "xen_common.h"
-#include "xen_driver_type.h"
#include "xen_vm_decl.h"
#include "xen_vtpm_decl.h"
@@ -67,8 +66,6 @@ typedef struct xen_vtpm_record
char *uuid;
struct xen_vm_record_opt *vm;
struct xen_vm_record_opt *backend;
- enum xen_driver_type driver;
- int64_t instance;
} xen_vtpm_record;
/**
@@ -198,19 +195,4 @@ xen_vtpm_get_vm(xen_session *session, xen_vm *result, xen_vtpm vtpm);
extern bool
xen_vtpm_get_backend(xen_session *session, xen_vm *result, xen_vtpm vtpm);
-
-/**
- * Get the driver field of the given VTPM.
- */
-extern bool
-xen_vtpm_get_driver(xen_session *session, enum xen_driver_type *result, xen_vtpm vtpm);
-
-
-/**
- * Get the instance field of the given VTPM.
- */
-extern bool
-xen_vtpm_get_instance(xen_session *session, int64_t *result, xen_vtpm vtpm);
-
-
#endif
diff --git a/tools/libxen/src/xen_cpu_feature.c b/tools/libxen/src/xen_cpu_feature.c
deleted file mode 100644
index 6f19f32704..0000000000
--- a/tools/libxen/src/xen_cpu_feature.c
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * Copyright (c) 2006, XenSource Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include <string.h>
-
-#include "xen_internal.h"
-#include "xen_cpu_feature.h"
-#include "xen_cpu_feature_internal.h"
-
-
-/*
- * Maintain this in the same order as the enum declaration!
- */
-static const char *lookup_table[] =
-{
- "FPU",
- "VME",
- "DE",
- "PSE",
- "TSC",
- "MSR",
- "PAE",
- "MCE",
- "CX8",
- "APIC",
- "SEP",
- "MTRR",
- "PGE",
- "MCA",
- "CMOV",
- "PAT",
- "PSE36",
- "PN",
- "CLFLSH",
- "DTES",
- "ACPI",
- "MMX",
- "FXSR",
- "XMM",
- "XMM2",
- "SELFSNOOP",
- "HT",
- "ACC",
- "IA64",
- "SYSCALL",
- "MP",
- "NX",
- "MMXEXT",
- "LM",
- "THREEDNOWEXT",
- "THREEDNOW",
- "RECOVERY",
- "LONGRUN",
- "LRTI",
- "CXMMX",
- "K6_MTRR",
- "CYRIX_ARR",
- "CENTAUR_MCR",
- "K8",
- "K7",
- "P3",
- "P4",
- "CONSTANT_TSC",
- "FXSAVE_LEAK",
- "XMM3",
- "MWAIT",
- "DSCPL",
- "EST",
- "TM2",
- "CID",
- "CX16",
- "XTPR",
- "XSTORE",
- "XSTORE_EN",
- "XCRYPT",
- "XCRYPT_EN",
- "LAHF_LM",
- "CMP_LEGACY",
- "VMX"
-};
-
-
-extern xen_cpu_feature_set *
-xen_cpu_feature_set_alloc(size_t size)
-{
- return calloc(1, sizeof(xen_cpu_feature_set) +
- size * sizeof(enum xen_cpu_feature));
-}
-
-
-extern void
-xen_cpu_feature_set_free(xen_cpu_feature_set *set)
-{
- free(set);
-}
-
-
-const char *
-xen_cpu_feature_to_string(enum xen_cpu_feature val)
-{
- return lookup_table[val];
-}
-
-
-extern enum xen_cpu_feature
-xen_cpu_feature_from_string(xen_session *session, const char *str)
-{
- return ENUM_LOOKUP(session, str, lookup_table);
-}
-
-
-const abstract_type xen_cpu_feature_abstract_type_ =
- {
- .typename = ENUM,
- .enum_marshaller =
- (const char *(*)(int))&xen_cpu_feature_to_string,
- .enum_demarshaller =
- (int (*)(xen_session *, const char *))&xen_cpu_feature_from_string
- };
-
-
-const abstract_type xen_cpu_feature_set_abstract_type_ =
- {
- .typename = SET,
- .child = &xen_cpu_feature_abstract_type_
- };
-
-
diff --git a/tools/libxen/src/xen_crashdump.c b/tools/libxen/src/xen_crashdump.c
new file mode 100644
index 0000000000..53504ba249
--- /dev/null
+++ b/tools/libxen/src/xen_crashdump.c
@@ -0,0 +1,199 @@
+/*
+ * Copyright (c) 2006, XenSource Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+
+#include <stddef.h>
+#include <stdlib.h>
+
+#include "xen_common.h"
+#include "xen_crashdump.h"
+#include "xen_internal.h"
+#include "xen_vdi.h"
+#include "xen_vm.h"
+
+
+XEN_FREE(xen_crashdump)
+XEN_SET_ALLOC_FREE(xen_crashdump)
+XEN_ALLOC(xen_crashdump_record)
+XEN_SET_ALLOC_FREE(xen_crashdump_record)
+XEN_ALLOC(xen_crashdump_record_opt)
+XEN_RECORD_OPT_FREE(xen_crashdump)
+XEN_SET_ALLOC_FREE(xen_crashdump_record_opt)
+
+
+static const struct_member xen_crashdump_record_struct_members[] =
+ {
+ { .key = "uuid",
+ .type = &abstract_type_string,
+ .offset = offsetof(xen_crashdump_record, uuid) },
+ { .key = "VM",
+ .type = &abstract_type_ref,
+ .offset = offsetof(xen_crashdump_record, vm) },
+ { .key = "VDI",
+ .type = &abstract_type_ref,
+ .offset = offsetof(xen_crashdump_record, vdi) }
+ };
+
+const abstract_type xen_crashdump_record_abstract_type_ =
+ {
+ .typename = STRUCT,
+ .struct_size = sizeof(xen_crashdump_record),
+ .member_count =
+ sizeof(xen_crashdump_record_struct_members) / sizeof(struct_member),
+ .members = xen_crashdump_record_struct_members
+ };
+
+
+void
+xen_crashdump_record_free(xen_crashdump_record *record)
+{
+ if (record == NULL)
+ {
+ return;
+ }
+ free(record->handle);
+ free(record->uuid);
+ xen_vm_record_opt_free(record->vm);
+ xen_vdi_record_opt_free(record->vdi);
+ free(record);
+}
+
+
+bool
+xen_crashdump_get_record(xen_session *session, xen_crashdump_record **result, xen_crashdump crashdump)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = crashdump }
+ };
+
+ abstract_type result_type = xen_crashdump_record_abstract_type_;
+
+ *result = NULL;
+ XEN_CALL_("crashdump.get_record");
+
+ if (session->ok)
+ {
+ (*result)->handle = xen_strdup_((*result)->uuid);
+ }
+
+ return session->ok;
+}
+
+
+bool
+xen_crashdump_get_by_uuid(xen_session *session, xen_crashdump *result, char *uuid)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = uuid }
+ };
+
+ abstract_type result_type = abstract_type_string;
+
+ *result = NULL;
+ XEN_CALL_("crashdump.get_by_uuid");
+ return session->ok;
+}
+
+
+bool
+xen_crashdump_create(xen_session *session, xen_crashdump *result, xen_crashdump_record *record)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &xen_crashdump_record_abstract_type_,
+ .u.struct_val = record }
+ };
+
+ abstract_type result_type = abstract_type_string;
+
+ *result = NULL;
+ XEN_CALL_("crashdump.create");
+ return session->ok;
+}
+
+
+bool
+xen_crashdump_destroy(xen_session *session, xen_crashdump crashdump)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = crashdump }
+ };
+
+ xen_call_(session, "crashdump.destroy", param_values, 1, NULL, NULL);
+ return session->ok;
+}
+
+
+bool
+xen_crashdump_get_vm(xen_session *session, xen_vm *result, xen_crashdump crashdump)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = crashdump }
+ };
+
+ abstract_type result_type = abstract_type_string;
+
+ *result = NULL;
+ XEN_CALL_("crashdump.get_VM");
+ return session->ok;
+}
+
+
+bool
+xen_crashdump_get_vdi(xen_session *session, xen_vdi *result, xen_crashdump crashdump)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = crashdump }
+ };
+
+ abstract_type result_type = abstract_type_string;
+
+ *result = NULL;
+ XEN_CALL_("crashdump.get_VDI");
+ return session->ok;
+}
+
+
+bool
+xen_crashdump_get_all(xen_session *session, struct xen_crashdump_set **result)
+{
+
+ abstract_type result_type = abstract_type_string_set;
+
+ *result = NULL;
+ xen_call_(session, "crashdump.get_all", NULL, 0, &result_type, result);
+ return session->ok;
+}
+
+
+bool
+xen_crashdump_get_uuid(xen_session *session, char **result, xen_crashdump crashdump)
+{
+ *result = session->ok ? xen_strdup_((char *)crashdump) : NULL;
+ return session->ok;
+}
diff --git a/tools/libxen/src/xen_driver_type.c b/tools/libxen/src/xen_driver_type.c
deleted file mode 100644
index fe95d84f0c..0000000000
--- a/tools/libxen/src/xen_driver_type.c
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright (c) 2006, XenSource Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include <string.h>
-
-#include "xen_internal.h"
-#include "xen_driver_type.h"
-#include "xen_driver_type_internal.h"
-
-
-/*
- * Maintain this in the same order as the enum declaration!
- */
-static const char *lookup_table[] =
-{
- "ioemu",
- "paravirtualised"
-};
-
-
-extern xen_driver_type_set *
-xen_driver_type_set_alloc(size_t size)
-{
- return calloc(1, sizeof(xen_driver_type_set) +
- size * sizeof(enum xen_driver_type));
-}
-
-
-extern void
-xen_driver_type_set_free(xen_driver_type_set *set)
-{
- free(set);
-}
-
-
-const char *
-xen_driver_type_to_string(enum xen_driver_type val)
-{
- return lookup_table[val];
-}
-
-
-extern enum xen_driver_type
-xen_driver_type_from_string(xen_session *session, const char *str)
-{
- return ENUM_LOOKUP(session, str, lookup_table);
-}
-
-
-const abstract_type xen_driver_type_abstract_type_ =
- {
- .typename = ENUM,
- .enum_marshaller =
- (const char *(*)(int))&xen_driver_type_to_string,
- .enum_demarshaller =
- (int (*)(xen_session *, const char *))&xen_driver_type_from_string
- };
-
-
-const abstract_type xen_driver_type_set_abstract_type_ =
- {
- .typename = SET,
- .child = &xen_driver_type_abstract_type_
- };
-
-
diff --git a/tools/libxen/src/xen_host.c b/tools/libxen/src/xen_host.c
index 931a0c44ce..7968b96994 100644
--- a/tools/libxen/src/xen_host.c
+++ b/tools/libxen/src/xen_host.c
@@ -23,8 +23,11 @@
#include "xen_common.h"
#include "xen_host.h"
#include "xen_host_cpu.h"
+#include "xen_host_metrics.h"
#include "xen_internal.h"
+#include "xen_pbd.h"
#include "xen_pif.h"
+#include "xen_sr.h"
#include "xen_string_string_map.h"
#include "xen_vm.h"
@@ -52,15 +55,33 @@ static const struct_member xen_host_record_struct_members[] =
{ .key = "software_version",
.type = &abstract_type_string_string_map,
.offset = offsetof(xen_host_record, software_version) },
+ { .key = "other_config",
+ .type = &abstract_type_string_string_map,
+ .offset = offsetof(xen_host_record, other_config) },
{ .key = "resident_VMs",
.type = &abstract_type_ref_set,
.offset = offsetof(xen_host_record, resident_vms) },
+ { .key = "logging",
+ .type = &abstract_type_string_string_map,
+ .offset = offsetof(xen_host_record, logging) },
{ .key = "PIFs",
.type = &abstract_type_ref_set,
.offset = offsetof(xen_host_record, pifs) },
+ { .key = "suspend_image_sr",
+ .type = &abstract_type_ref,
+ .offset = offsetof(xen_host_record, suspend_image_sr) },
+ { .key = "crash_dump_sr",
+ .type = &abstract_type_ref,
+ .offset = offsetof(xen_host_record, crash_dump_sr) },
+ { .key = "PBDs",
+ .type = &abstract_type_ref_set,
+ .offset = offsetof(xen_host_record, pbds) },
{ .key = "host_CPUs",
.type = &abstract_type_ref_set,
- .offset = offsetof(xen_host_record, host_cpus) }
+ .offset = offsetof(xen_host_record, host_cpus) },
+ { .key = "metrics",
+ .type = &abstract_type_ref,
+ .offset = offsetof(xen_host_record, metrics) }
};
const abstract_type xen_host_record_abstract_type_ =
@@ -85,9 +106,15 @@ xen_host_record_free(xen_host_record *record)
free(record->name_label);
free(record->name_description);
xen_string_string_map_free(record->software_version);
+ xen_string_string_map_free(record->other_config);
xen_vm_record_opt_set_free(record->resident_vms);
+ xen_string_string_map_free(record->logging);
xen_pif_record_opt_set_free(record->pifs);
+ xen_sr_record_opt_free(record->suspend_image_sr);
+ xen_sr_record_opt_free(record->crash_dump_sr);
+ xen_pbd_record_opt_set_free(record->pbds);
xen_host_cpu_record_opt_set_free(record->host_cpus);
+ xen_host_metrics_record_opt_free(record->metrics);
free(record);
}
@@ -232,6 +259,23 @@ xen_host_get_software_version(xen_session *session, xen_string_string_map **resu
bool
+xen_host_get_other_config(xen_session *session, xen_string_string_map **result, xen_host host)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = host }
+ };
+
+ abstract_type result_type = abstract_type_string_string_map;
+
+ *result = NULL;
+ XEN_CALL_("host.get_other_config");
+ return session->ok;
+}
+
+
+bool
xen_host_get_resident_vms(xen_session *session, struct xen_vm_set **result, xen_host host)
{
abstract_value param_values[] =
@@ -249,6 +293,23 @@ xen_host_get_resident_vms(xen_session *session, struct xen_vm_set **result, xen_
bool
+xen_host_get_logging(xen_session *session, xen_string_string_map **result, xen_host host)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = host }
+ };
+
+ abstract_type result_type = abstract_type_string_string_map;
+
+ *result = NULL;
+ XEN_CALL_("host.get_logging");
+ return session->ok;
+}
+
+
+bool
xen_host_get_pifs(xen_session *session, struct xen_pif_set **result, xen_host host)
{
abstract_value param_values[] =
@@ -266,6 +327,57 @@ xen_host_get_pifs(xen_session *session, struct xen_pif_set **result, xen_host ho
bool
+xen_host_get_suspend_image_sr(xen_session *session, xen_sr *result, xen_host host)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = host }
+ };
+
+ abstract_type result_type = abstract_type_string;
+
+ *result = NULL;
+ XEN_CALL_("host.get_suspend_image_sr");
+ return session->ok;
+}
+
+
+bool
+xen_host_get_crash_dump_sr(xen_session *session, xen_sr *result, xen_host host)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = host }
+ };
+
+ abstract_type result_type = abstract_type_string;
+
+ *result = NULL;
+ XEN_CALL_("host.get_crash_dump_sr");
+ return session->ok;
+}
+
+
+bool
+xen_host_get_pbds(xen_session *session, struct xen_pbd_set **result, xen_host host)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = host }
+ };
+
+ abstract_type result_type = abstract_type_string_set;
+
+ *result = NULL;
+ XEN_CALL_("host.get_PBDs");
+ return session->ok;
+}
+
+
+bool
xen_host_get_host_cpus(xen_session *session, struct xen_host_cpu_set **result, xen_host host)
{
abstract_value param_values[] =
@@ -283,6 +395,23 @@ xen_host_get_host_cpus(xen_session *session, struct xen_host_cpu_set **result, x
bool
+xen_host_get_metrics(xen_session *session, xen_host_metrics *result, xen_host host)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = host }
+ };
+
+ abstract_type result_type = abstract_type_string;
+
+ *result = NULL;
+ XEN_CALL_("host.get_metrics");
+ return session->ok;
+}
+
+
+bool
xen_host_set_name_label(xen_session *session, xen_host host, char *label)
{
abstract_value param_values[] =
@@ -315,6 +444,138 @@ xen_host_set_name_description(xen_session *session, xen_host host, char *descrip
bool
+xen_host_set_other_config(xen_session *session, xen_host host, xen_string_string_map *other_config)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = host },
+ { .type = &abstract_type_string_string_map,
+ .u.set_val = (arbitrary_set *)other_config }
+ };
+
+ xen_call_(session, "host.set_other_config", param_values, 2, NULL, NULL);
+ return session->ok;
+}
+
+
+bool
+xen_host_add_to_other_config(xen_session *session, xen_host host, char *key, char *value)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = host },
+ { .type = &abstract_type_string,
+ .u.string_val = key },
+ { .type = &abstract_type_string,
+ .u.string_val = value }
+ };
+
+ xen_call_(session, "host.add_to_other_config", param_values, 3, NULL, NULL);
+ return session->ok;
+}
+
+
+bool
+xen_host_remove_from_other_config(xen_session *session, xen_host host, char *key)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = host },
+ { .type = &abstract_type_string,
+ .u.string_val = key }
+ };
+
+ xen_call_(session, "host.remove_from_other_config", param_values, 2, NULL, NULL);
+ return session->ok;
+}
+
+
+bool
+xen_host_set_logging(xen_session *session, xen_host host, xen_string_string_map *logging)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = host },
+ { .type = &abstract_type_string_string_map,
+ .u.set_val = (arbitrary_set *)logging }
+ };
+
+ xen_call_(session, "host.set_logging", param_values, 2, NULL, NULL);
+ return session->ok;
+}
+
+
+bool
+xen_host_add_to_logging(xen_session *session, xen_host host, char *key, char *value)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = host },
+ { .type = &abstract_type_string,
+ .u.string_val = key },
+ { .type = &abstract_type_string,
+ .u.string_val = value }
+ };
+
+ xen_call_(session, "host.add_to_logging", param_values, 3, NULL, NULL);
+ return session->ok;
+}
+
+
+bool
+xen_host_remove_from_logging(xen_session *session, xen_host host, char *key)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = host },
+ { .type = &abstract_type_string,
+ .u.string_val = key }
+ };
+
+ xen_call_(session, "host.remove_from_logging", param_values, 2, NULL, NULL);
+ return session->ok;
+}
+
+
+bool
+xen_host_set_suspend_image_sr(xen_session *session, xen_host host, xen_sr suspend_image_sr)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = host },
+ { .type = &abstract_type_string,
+ .u.string_val = suspend_image_sr }
+ };
+
+ xen_call_(session, "host.set_suspend_image_sr", param_values, 2, NULL, NULL);
+ return session->ok;
+}
+
+
+bool
+xen_host_set_crash_dump_sr(xen_session *session, xen_host host, xen_sr crash_dump_sr)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = host },
+ { .type = &abstract_type_string,
+ .u.string_val = crash_dump_sr }
+ };
+
+ xen_call_(session, "host.set_crash_dump_sr", param_values, 2, NULL, NULL);
+ return session->ok;
+}
+
+
+bool
xen_host_disable(xen_session *session, xen_host host)
{
abstract_value param_values[] =
diff --git a/tools/libxen/src/xen_host_cpu.c b/tools/libxen/src/xen_host_cpu.c
index ff73dcd9b9..1300ce0e43 100644
--- a/tools/libxen/src/xen_host_cpu.c
+++ b/tools/libxen/src/xen_host_cpu.c
@@ -21,8 +21,6 @@
#include <stdlib.h>
#include "xen_common.h"
-#include "xen_cpu_feature.h"
-#include "xen_cpu_feature_internal.h"
#include "xen_host.h"
#include "xen_host_cpu.h"
#include "xen_internal.h"
@@ -57,9 +55,6 @@ static const struct_member xen_host_cpu_record_struct_members[] =
{ .key = "modelname",
.type = &abstract_type_string,
.offset = offsetof(xen_host_cpu_record, modelname) },
- { .key = "features",
- .type = &xen_cpu_feature_set_abstract_type_,
- .offset = offsetof(xen_host_cpu_record, features) },
{ .key = "utilisation",
.type = &abstract_type_float,
.offset = offsetof(xen_host_cpu_record, utilisation) }
@@ -87,7 +82,6 @@ xen_host_cpu_record_free(xen_host_cpu_record *record)
xen_host_record_opt_free(record->host);
free(record->vendor);
free(record->modelname);
- xen_cpu_feature_set_free(record->features);
free(record);
}
@@ -247,23 +241,6 @@ xen_host_cpu_get_modelname(xen_session *session, char **result, xen_host_cpu hos
bool
-xen_host_cpu_get_features(xen_session *session, struct xen_cpu_feature_set **result, xen_host_cpu host_cpu)
-{
- abstract_value param_values[] =
- {
- { .type = &abstract_type_string,
- .u.string_val = host_cpu }
- };
-
- abstract_type result_type = xen_cpu_feature_set_abstract_type_;
-
- *result = NULL;
- XEN_CALL_("host_cpu.get_features");
- return session->ok;
-}
-
-
-bool
xen_host_cpu_get_utilisation(xen_session *session, double *result, xen_host_cpu host_cpu)
{
abstract_value param_values[] =
diff --git a/tools/libxen/src/xen_host_metrics.c b/tools/libxen/src/xen_host_metrics.c
new file mode 100644
index 0000000000..910ca229ec
--- /dev/null
+++ b/tools/libxen/src/xen_host_metrics.c
@@ -0,0 +1,172 @@
+/*
+ * Copyright (c) 2006, XenSource Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+
+#include <stddef.h>
+#include <stdlib.h>
+
+#include "xen_common.h"
+#include "xen_host.h"
+#include "xen_host_metrics.h"
+#include "xen_internal.h"
+
+
+XEN_FREE(xen_host_metrics)
+XEN_SET_ALLOC_FREE(xen_host_metrics)
+XEN_ALLOC(xen_host_metrics_record)
+XEN_SET_ALLOC_FREE(xen_host_metrics_record)
+XEN_ALLOC(xen_host_metrics_record_opt)
+XEN_RECORD_OPT_FREE(xen_host_metrics)
+XEN_SET_ALLOC_FREE(xen_host_metrics_record_opt)
+
+
+static const struct_member xen_host_metrics_record_struct_members[] =
+ {
+ { .key = "uuid",
+ .type = &abstract_type_string,
+ .offset = offsetof(xen_host_metrics_record, uuid) },
+ { .key = "host",
+ .type = &abstract_type_ref,
+ .offset = offsetof(xen_host_metrics_record, host) },
+ { .key = "memory_total",
+ .type = &abstract_type_int,
+ .offset = offsetof(xen_host_metrics_record, memory_total) },
+ { .key = "memory_free",
+ .type = &abstract_type_int,
+ .offset = offsetof(xen_host_metrics_record, memory_free) }
+ };
+
+const abstract_type xen_host_metrics_record_abstract_type_ =
+ {
+ .typename = STRUCT,
+ .struct_size = sizeof(xen_host_metrics_record),
+ .member_count =
+ sizeof(xen_host_metrics_record_struct_members) / sizeof(struct_member),
+ .members = xen_host_metrics_record_struct_members
+ };
+
+
+void
+xen_host_metrics_record_free(xen_host_metrics_record *record)
+{
+ if (record == NULL)
+ {
+ return;
+ }
+ free(record->handle);
+ free(record->uuid);
+ xen_host_record_opt_free(record->host);
+ free(record);
+}
+
+
+bool
+xen_host_metrics_get_record(xen_session *session, xen_host_metrics_record **result, xen_host_metrics host_metrics)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = host_metrics }
+ };
+
+ abstract_type result_type = xen_host_metrics_record_abstract_type_;
+
+ *result = NULL;
+ XEN_CALL_("host_metrics.get_record");
+
+ if (session->ok)
+ {
+ (*result)->handle = xen_strdup_((*result)->uuid);
+ }
+
+ return session->ok;
+}
+
+
+bool
+xen_host_metrics_get_by_uuid(xen_session *session, xen_host_metrics *result, char *uuid)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = uuid }
+ };
+
+ abstract_type result_type = abstract_type_string;
+
+ *result = NULL;
+ XEN_CALL_("host_metrics.get_by_uuid");
+ return session->ok;
+}
+
+
+bool
+xen_host_metrics_get_host(xen_session *session, xen_host *result, xen_host_metrics host_metrics)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = host_metrics }
+ };
+
+ abstract_type result_type = abstract_type_string;
+
+ *result = NULL;
+ XEN_CALL_("host_metrics.get_host");
+ return session->ok;
+}
+
+
+bool
+xen_host_metrics_get_memory_total(xen_session *session, int64_t *result, xen_host_metrics host_metrics)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = host_metrics }
+ };
+
+ abstract_type result_type = abstract_type_int;
+
+ XEN_CALL_("host_metrics.get_memory_total");
+ return session->ok;
+}
+
+
+bool
+xen_host_metrics_get_memory_free(xen_session *session, int64_t *result, xen_host_metrics host_metrics)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = host_metrics }
+ };
+
+ abstract_type result_type = abstract_type_int;
+
+ XEN_CALL_("host_metrics.get_memory_free");
+ return session->ok;
+}
+
+
+bool
+xen_host_metrics_get_uuid(xen_session *session, char **result, xen_host_metrics host_metrics)
+{
+ *result = session->ok ? xen_strdup_((char *)host_metrics) : NULL;
+ return session->ok;
+}
diff --git a/tools/libxen/src/xen_pbd.c b/tools/libxen/src/xen_pbd.c
new file mode 100644
index 0000000000..cb7ac9df72
--- /dev/null
+++ b/tools/libxen/src/xen_pbd.c
@@ -0,0 +1,228 @@
+/*
+ * Copyright (c) 2006, XenSource Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+
+#include <stddef.h>
+#include <stdlib.h>
+
+#include "xen_common.h"
+#include "xen_host.h"
+#include "xen_internal.h"
+#include "xen_pbd.h"
+#include "xen_sr.h"
+#include "xen_string_string_map.h"
+
+
+XEN_FREE(xen_pbd)
+XEN_SET_ALLOC_FREE(xen_pbd)
+XEN_ALLOC(xen_pbd_record)
+XEN_SET_ALLOC_FREE(xen_pbd_record)
+XEN_ALLOC(xen_pbd_record_opt)
+XEN_RECORD_OPT_FREE(xen_pbd)
+XEN_SET_ALLOC_FREE(xen_pbd_record_opt)
+
+
+static const struct_member xen_pbd_record_struct_members[] =
+ {
+ { .key = "uuid",
+ .type = &abstract_type_string,
+ .offset = offsetof(xen_pbd_record, uuid) },
+ { .key = "host",
+ .type = &abstract_type_ref,
+ .offset = offsetof(xen_pbd_record, host) },
+ { .key = "SR",
+ .type = &abstract_type_ref,
+ .offset = offsetof(xen_pbd_record, sr) },
+ { .key = "device_config",
+ .type = &abstract_type_string_string_map,
+ .offset = offsetof(xen_pbd_record, device_config) },
+ { .key = "currently_attached",
+ .type = &abstract_type_bool,
+ .offset = offsetof(xen_pbd_record, currently_attached) }
+ };
+
+const abstract_type xen_pbd_record_abstract_type_ =
+ {
+ .typename = STRUCT,
+ .struct_size = sizeof(xen_pbd_record),
+ .member_count =
+ sizeof(xen_pbd_record_struct_members) / sizeof(struct_member),
+ .members = xen_pbd_record_struct_members
+ };
+
+
+void
+xen_pbd_record_free(xen_pbd_record *record)
+{
+ if (record == NULL)
+ {
+ return;
+ }
+ free(record->handle);
+ free(record->uuid);
+ xen_host_record_opt_free(record->host);
+ xen_sr_record_opt_free(record->sr);
+ xen_string_string_map_free(record->device_config);
+ free(record);
+}
+
+
+bool
+xen_pbd_get_record(xen_session *session, xen_pbd_record **result, xen_pbd pbd)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = pbd }
+ };
+
+ abstract_type result_type = xen_pbd_record_abstract_type_;
+
+ *result = NULL;
+ XEN_CALL_("PBD.get_record");
+
+ if (session->ok)
+ {
+ (*result)->handle = xen_strdup_((*result)->uuid);
+ }
+
+ return session->ok;
+}
+
+
+bool
+xen_pbd_get_by_uuid(xen_session *session, xen_pbd *result, char *uuid)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = uuid }
+ };
+
+ abstract_type result_type = abstract_type_string;
+
+ *result = NULL;
+ XEN_CALL_("PBD.get_by_uuid");
+ return session->ok;
+}
+
+
+bool
+xen_pbd_create(xen_session *session, xen_pbd *result, xen_pbd_record *record)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &xen_pbd_record_abstract_type_,
+ .u.struct_val = record }
+ };
+
+ abstract_type result_type = abstract_type_string;
+
+ *result = NULL;
+ XEN_CALL_("PBD.create");
+ return session->ok;
+}
+
+
+bool
+xen_pbd_destroy(xen_session *session, xen_pbd pbd)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = pbd }
+ };
+
+ xen_call_(session, "PBD.destroy", param_values, 1, NULL, NULL);
+ return session->ok;
+}
+
+
+bool
+xen_pbd_get_host(xen_session *session, xen_host *result, xen_pbd pbd)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = pbd }
+ };
+
+ abstract_type result_type = abstract_type_string;
+
+ *result = NULL;
+ XEN_CALL_("PBD.get_host");
+ return session->ok;
+}
+
+
+bool
+xen_pbd_get_sr(xen_session *session, xen_sr *result, xen_pbd pbd)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = pbd }
+ };
+
+ abstract_type result_type = abstract_type_string;
+
+ *result = NULL;
+ XEN_CALL_("PBD.get_SR");
+ return session->ok;
+}
+
+
+bool
+xen_pbd_get_device_config(xen_session *session, xen_string_string_map **result, xen_pbd pbd)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = pbd }
+ };
+
+ abstract_type result_type = abstract_type_string_string_map;
+
+ *result = NULL;
+ XEN_CALL_("PBD.get_device_config");
+ return session->ok;
+}
+
+
+bool
+xen_pbd_get_currently_attached(xen_session *session, bool *result, xen_pbd pbd)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = pbd }
+ };
+
+ abstract_type result_type = abstract_type_bool;
+
+ XEN_CALL_("PBD.get_currently_attached");
+ return session->ok;
+}
+
+
+bool
+xen_pbd_get_uuid(xen_session *session, char **result, xen_pbd pbd)
+{
+ *result = session->ok ? xen_strdup_((char *)pbd) : NULL;
+ return session->ok;
+}
diff --git a/tools/libxen/src/xen_pif.c b/tools/libxen/src/xen_pif.c
index b3edd91e6d..0e9af6a382 100644
--- a/tools/libxen/src/xen_pif.c
+++ b/tools/libxen/src/xen_pif.c
@@ -25,6 +25,7 @@
#include "xen_internal.h"
#include "xen_network.h"
#include "xen_pif.h"
+#include "xen_pif_metrics.h"
XEN_FREE(xen_pif)
@@ -41,9 +42,9 @@ static const struct_member xen_pif_record_struct_members[] =
{ .key = "uuid",
.type = &abstract_type_string,
.offset = offsetof(xen_pif_record, uuid) },
- { .key = "name",
+ { .key = "device",
.type = &abstract_type_string,
- .offset = offsetof(xen_pif_record, name) },
+ .offset = offsetof(xen_pif_record, device) },
{ .key = "network",
.type = &abstract_type_ref,
.offset = offsetof(xen_pif_record, network) },
@@ -57,14 +58,11 @@ static const struct_member xen_pif_record_struct_members[] =
.type = &abstract_type_int,
.offset = offsetof(xen_pif_record, mtu) },
{ .key = "VLAN",
- .type = &abstract_type_string,
+ .type = &abstract_type_int,
.offset = offsetof(xen_pif_record, vlan) },
- { .key = "io_read_kbs",
- .type = &abstract_type_float,
- .offset = offsetof(xen_pif_record, io_read_kbs) },
- { .key = "io_write_kbs",
- .type = &abstract_type_float,
- .offset = offsetof(xen_pif_record, io_write_kbs) }
+ { .key = "metrics",
+ .type = &abstract_type_ref,
+ .offset = offsetof(xen_pif_record, metrics) }
};
const abstract_type xen_pif_record_abstract_type_ =
@@ -86,11 +84,11 @@ xen_pif_record_free(xen_pif_record *record)
}
free(record->handle);
free(record->uuid);
- free(record->name);
+ free(record->device);
xen_network_record_opt_free(record->network);
xen_host_record_opt_free(record->host);
free(record->mac);
- free(record->vlan);
+ xen_pif_metrics_record_opt_free(record->metrics);
free(record);
}
@@ -136,38 +134,7 @@ xen_pif_get_by_uuid(xen_session *session, xen_pif *result, char *uuid)
bool
-xen_pif_create(xen_session *session, xen_pif *result, xen_pif_record *record)
-{
- abstract_value param_values[] =
- {
- { .type = &xen_pif_record_abstract_type_,
- .u.struct_val = record }
- };
-
- abstract_type result_type = abstract_type_string;
-
- *result = NULL;
- XEN_CALL_("PIF.create");
- return session->ok;
-}
-
-
-bool
-xen_pif_destroy(xen_session *session, xen_pif pif)
-{
- abstract_value param_values[] =
- {
- { .type = &abstract_type_string,
- .u.string_val = pif }
- };
-
- xen_call_(session, "PIF.destroy", param_values, 1, NULL, NULL);
- return session->ok;
-}
-
-
-bool
-xen_pif_get_name(xen_session *session, char **result, xen_pif pif)
+xen_pif_get_device(xen_session *session, char **result, xen_pif pif)
{
abstract_value param_values[] =
{
@@ -178,7 +145,7 @@ xen_pif_get_name(xen_session *session, char **result, xen_pif pif)
abstract_type result_type = abstract_type_string;
*result = NULL;
- XEN_CALL_("PIF.get_name");
+ XEN_CALL_("PIF.get_device");
return session->ok;
}
@@ -251,7 +218,7 @@ xen_pif_get_mtu(xen_session *session, int64_t *result, xen_pif pif)
bool
-xen_pif_get_vlan(xen_session *session, char **result, xen_pif pif)
+xen_pif_get_vlan(xen_session *session, int64_t *result, xen_pif pif)
{
abstract_value param_values[] =
{
@@ -259,32 +226,15 @@ xen_pif_get_vlan(xen_session *session, char **result, xen_pif pif)
.u.string_val = pif }
};
- abstract_type result_type = abstract_type_string;
+ abstract_type result_type = abstract_type_int;
- *result = NULL;
XEN_CALL_("PIF.get_VLAN");
return session->ok;
}
bool
-xen_pif_get_io_read_kbs(xen_session *session, double *result, xen_pif pif)
-{
- abstract_value param_values[] =
- {
- { .type = &abstract_type_string,
- .u.string_val = pif }
- };
-
- abstract_type result_type = abstract_type_float;
-
- XEN_CALL_("PIF.get_io_read_kbs");
- return session->ok;
-}
-
-
-bool
-xen_pif_get_io_write_kbs(xen_session *session, double *result, xen_pif pif)
+xen_pif_get_metrics(xen_session *session, xen_pif_metrics *result, xen_pif pif)
{
abstract_value param_values[] =
{
@@ -292,105 +242,111 @@ xen_pif_get_io_write_kbs(xen_session *session, double *result, xen_pif pif)
.u.string_val = pif }
};
- abstract_type result_type = abstract_type_float;
+ abstract_type result_type = abstract_type_string;
- XEN_CALL_("PIF.get_io_write_kbs");
+ *result = NULL;
+ XEN_CALL_("PIF.get_metrics");
return session->ok;
}
bool
-xen_pif_set_name(xen_session *session, xen_pif pif, char *name)
+xen_pif_set_device(xen_session *session, xen_pif pif, char *device)
{
abstract_value param_values[] =
{
{ .type = &abstract_type_string,
.u.string_val = pif },
{ .type = &abstract_type_string,
- .u.string_val = name }
+ .u.string_val = device }
};
- xen_call_(session, "PIF.set_name", param_values, 2, NULL, NULL);
+ xen_call_(session, "PIF.set_device", param_values, 2, NULL, NULL);
return session->ok;
}
bool
-xen_pif_set_network(xen_session *session, xen_pif pif, xen_network network)
+xen_pif_set_mac(xen_session *session, xen_pif pif, char *mac)
{
abstract_value param_values[] =
{
{ .type = &abstract_type_string,
.u.string_val = pif },
{ .type = &abstract_type_string,
- .u.string_val = network }
+ .u.string_val = mac }
};
- xen_call_(session, "PIF.set_network", param_values, 2, NULL, NULL);
+ xen_call_(session, "PIF.set_MAC", param_values, 2, NULL, NULL);
return session->ok;
}
bool
-xen_pif_set_host(xen_session *session, xen_pif pif, xen_host host)
+xen_pif_set_mtu(xen_session *session, xen_pif pif, int64_t mtu)
{
abstract_value param_values[] =
{
{ .type = &abstract_type_string,
.u.string_val = pif },
- { .type = &abstract_type_string,
- .u.string_val = host }
+ { .type = &abstract_type_int,
+ .u.int_val = mtu }
};
- xen_call_(session, "PIF.set_host", param_values, 2, NULL, NULL);
+ xen_call_(session, "PIF.set_MTU", param_values, 2, NULL, NULL);
return session->ok;
}
bool
-xen_pif_set_mac(xen_session *session, xen_pif pif, char *mac)
+xen_pif_set_vlan(xen_session *session, xen_pif pif, int64_t vlan)
{
abstract_value param_values[] =
{
{ .type = &abstract_type_string,
.u.string_val = pif },
- { .type = &abstract_type_string,
- .u.string_val = mac }
+ { .type = &abstract_type_int,
+ .u.int_val = vlan }
};
- xen_call_(session, "PIF.set_MAC", param_values, 2, NULL, NULL);
+ xen_call_(session, "PIF.set_VLAN", param_values, 2, NULL, NULL);
return session->ok;
}
bool
-xen_pif_set_mtu(xen_session *session, xen_pif pif, int64_t mtu)
+xen_pif_create_vlan(xen_session *session, xen_pif *result, char *device, xen_network network, xen_host host, int64_t vlan)
{
abstract_value param_values[] =
{
{ .type = &abstract_type_string,
- .u.string_val = pif },
+ .u.string_val = device },
+ { .type = &abstract_type_string,
+ .u.string_val = network },
+ { .type = &abstract_type_string,
+ .u.string_val = host },
{ .type = &abstract_type_int,
- .u.int_val = mtu }
+ .u.int_val = vlan }
};
- xen_call_(session, "PIF.set_MTU", param_values, 2, NULL, NULL);
+ abstract_type result_type = abstract_type_string;
+
+ *result = NULL;
+ XEN_CALL_("PIF.create_VLAN");
return session->ok;
}
bool
-xen_pif_set_vlan(xen_session *session, xen_pif pif, char *vlan)
+xen_pif_destroy(xen_session *session, xen_pif self)
{
abstract_value param_values[] =
{
{ .type = &abstract_type_string,
- .u.string_val = pif },
- { .type = &abstract_type_string,
- .u.string_val = vlan }
+ .u.string_val = self }
};
- xen_call_(session, "PIF.set_VLAN", param_values, 2, NULL, NULL);
+ xen_call_(session, "PIF.destroy", param_values, 1, NULL, NULL);
return session->ok;
}
diff --git a/tools/libxen/src/xen_pif_metrics.c b/tools/libxen/src/xen_pif_metrics.c
new file mode 100644
index 0000000000..3f09ae7dc1
--- /dev/null
+++ b/tools/libxen/src/xen_pif_metrics.c
@@ -0,0 +1,172 @@
+/*
+ * Copyright (c) 2006, XenSource Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+
+#include <stddef.h>
+#include <stdlib.h>
+
+#include "xen_common.h"
+#include "xen_internal.h"
+#include "xen_pif.h"
+#include "xen_pif_metrics.h"
+
+
+XEN_FREE(xen_pif_metrics)
+XEN_SET_ALLOC_FREE(xen_pif_metrics)
+XEN_ALLOC(xen_pif_metrics_record)
+XEN_SET_ALLOC_FREE(xen_pif_metrics_record)
+XEN_ALLOC(xen_pif_metrics_record_opt)
+XEN_RECORD_OPT_FREE(xen_pif_metrics)
+XEN_SET_ALLOC_FREE(xen_pif_metrics_record_opt)
+
+
+static const struct_member xen_pif_metrics_record_struct_members[] =
+ {
+ { .key = "uuid",
+ .type = &abstract_type_string,
+ .offset = offsetof(xen_pif_metrics_record, uuid) },
+ { .key = "PIF",
+ .type = &abstract_type_ref,
+ .offset = offsetof(xen_pif_metrics_record, pif) },
+ { .key = "io_read_kbs",
+ .type = &abstract_type_float,
+ .offset = offsetof(xen_pif_metrics_record, io_read_kbs) },
+ { .key = "io_write_kbs",
+ .type = &abstract_type_float,
+ .offset = offsetof(xen_pif_metrics_record, io_write_kbs) }
+ };
+
+const abstract_type xen_pif_metrics_record_abstract_type_ =
+ {
+ .typename = STRUCT,
+ .struct_size = sizeof(xen_pif_metrics_record),
+ .member_count =
+ sizeof(xen_pif_metrics_record_struct_members) / sizeof(struct_member),
+ .members = xen_pif_metrics_record_struct_members
+ };
+
+
+void
+xen_pif_metrics_record_free(xen_pif_metrics_record *record)
+{
+ if (record == NULL)
+ {
+ return;
+ }
+ free(record->handle);
+ free(record->uuid);
+ xen_pif_record_opt_free(record->pif);
+ free(record);
+}
+
+
+bool
+xen_pif_metrics_get_record(xen_session *session, xen_pif_metrics_record **result, xen_pif_metrics pif_metrics)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = pif_metrics }
+ };
+
+ abstract_type result_type = xen_pif_metrics_record_abstract_type_;
+
+ *result = NULL;
+ XEN_CALL_("PIF_metrics.get_record");
+
+ if (session->ok)
+ {
+ (*result)->handle = xen_strdup_((*result)->uuid);
+ }
+
+ return session->ok;
+}
+
+
+bool
+xen_pif_metrics_get_by_uuid(xen_session *session, xen_pif_metrics *result, char *uuid)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = uuid }
+ };
+
+ abstract_type result_type = abstract_type_string;
+
+ *result = NULL;
+ XEN_CALL_("PIF_metrics.get_by_uuid");
+ return session->ok;
+}
+
+
+bool
+xen_pif_metrics_get_pif(xen_session *session, xen_pif *result, xen_pif_metrics pif_metrics)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = pif_metrics }
+ };
+
+ abstract_type result_type = abstract_type_string;
+
+ *result = NULL;
+ XEN_CALL_("PIF_metrics.get_PIF");
+ return session->ok;
+}
+
+
+bool
+xen_pif_metrics_get_io_read_kbs(xen_session *session, double *result, xen_pif_metrics pif_metrics)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = pif_metrics }
+ };
+
+ abstract_type result_type = abstract_type_float;
+
+ XEN_CALL_("PIF_metrics.get_io_read_kbs");
+ return session->ok;
+}
+
+
+bool
+xen_pif_metrics_get_io_write_kbs(xen_session *session, double *result, xen_pif_metrics pif_metrics)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = pif_metrics }
+ };
+
+ abstract_type result_type = abstract_type_float;
+
+ XEN_CALL_("PIF_metrics.get_io_write_kbs");
+ return session->ok;
+}
+
+
+bool
+xen_pif_metrics_get_uuid(xen_session *session, char **result, xen_pif_metrics pif_metrics)
+{
+ *result = session->ok ? xen_strdup_((char *)pif_metrics) : NULL;
+ return session->ok;
+}
diff --git a/tools/libxen/src/xen_sr.c b/tools/libxen/src/xen_sr.c
index 3c4ffb16de..c3650f26a0 100644
--- a/tools/libxen/src/xen_sr.c
+++ b/tools/libxen/src/xen_sr.c
@@ -22,6 +22,7 @@
#include "xen_common.h"
#include "xen_internal.h"
+#include "xen_pbd.h"
#include "xen_sr.h"
#include "xen_vdi.h"
@@ -49,6 +50,9 @@ static const struct_member xen_sr_record_struct_members[] =
{ .key = "VDIs",
.type = &abstract_type_ref_set,
.offset = offsetof(xen_sr_record, vdis) },
+ { .key = "PBDs",
+ .type = &abstract_type_ref_set,
+ .offset = offsetof(xen_sr_record, pbds) },
{ .key = "virtual_allocation",
.type = &abstract_type_int,
.offset = offsetof(xen_sr_record, virtual_allocation) },
@@ -88,6 +92,7 @@ xen_sr_record_free(xen_sr_record *record)
free(record->name_label);
free(record->name_description);
xen_vdi_record_opt_set_free(record->vdis);
+ xen_pbd_record_opt_set_free(record->pbds);
free(record->type);
free(record->location);
free(record);
diff --git a/tools/libxen/src/xen_vbd.c b/tools/libxen/src/xen_vbd.c
index c49ecf236a..786c7ea896 100644
--- a/tools/libxen/src/xen_vbd.c
+++ b/tools/libxen/src/xen_vbd.c
@@ -21,7 +21,6 @@
#include <stdlib.h>
#include "xen_common.h"
-#include "xen_driver_type_internal.h"
#include "xen_internal.h"
#include "xen_vbd.h"
#include "xen_vbd_mode_internal.h"
@@ -55,12 +54,12 @@ static const struct_member xen_vbd_record_struct_members[] =
{ .key = "image",
.type = &abstract_type_string,
.offset = offsetof(xen_vbd_record, image) },
+ { .key = "bootable",
+ .type = &abstract_type_bool,
+ .offset = offsetof(xen_vbd_record, bootable) },
{ .key = "mode",
.type = &xen_vbd_mode_abstract_type_,
.offset = offsetof(xen_vbd_record, mode) },
- { .key = "driver",
- .type = &xen_driver_type_abstract_type_,
- .offset = offsetof(xen_vbd_record, driver) },
{ .key = "io_read_kbs",
.type = &abstract_type_float,
.offset = offsetof(xen_vbd_record, io_read_kbs) },
@@ -218,7 +217,7 @@ xen_vbd_get_device(xen_session *session, char **result, xen_vbd vbd)
bool
-xen_vbd_get_mode(xen_session *session, enum xen_vbd_mode *result, xen_vbd vbd)
+xen_vbd_get_bootable(xen_session *session, bool *result, xen_vbd vbd)
{
abstract_value param_values[] =
{
@@ -226,16 +225,15 @@ xen_vbd_get_mode(xen_session *session, enum xen_vbd_mode *result, xen_vbd vbd)
.u.string_val = vbd }
};
- abstract_type result_type = xen_vbd_mode_abstract_type_;
- char *result_str = NULL;
- XEN_CALL_("VBD.get_mode");
- *result = xen_vbd_mode_from_string(session, result_str);
+ abstract_type result_type = abstract_type_bool;
+
+ XEN_CALL_("VBD.get_bootable");
return session->ok;
}
bool
-xen_vbd_get_driver(xen_session *session, enum xen_driver_type *result, xen_vbd vbd)
+xen_vbd_get_mode(xen_session *session, enum xen_vbd_mode *result, xen_vbd vbd)
{
abstract_value param_values[] =
{
@@ -243,10 +241,10 @@ xen_vbd_get_driver(xen_session *session, enum xen_driver_type *result, xen_vbd v
.u.string_val = vbd }
};
- abstract_type result_type = xen_driver_type_abstract_type_;
+ abstract_type result_type = xen_vbd_mode_abstract_type_;
char *result_str = NULL;
- XEN_CALL_("VBD.get_driver");
- *result = xen_driver_type_from_string(session, result_str);
+ XEN_CALL_("VBD.get_mode");
+ *result = xen_vbd_mode_from_string(session, result_str);
return session->ok;
}
@@ -284,49 +282,33 @@ xen_vbd_get_io_write_kbs(xen_session *session, double *result, xen_vbd vbd)
bool
-xen_vbd_set_vm(xen_session *session, xen_vbd vbd, xen_vm vm)
-{
- abstract_value param_values[] =
- {
- { .type = &abstract_type_string,
- .u.string_val = vbd },
- { .type = &abstract_type_string,
- .u.string_val = vm }
- };
-
- xen_call_(session, "VBD.set_VM", param_values, 2, NULL, NULL);
- return session->ok;
-}
-
-
-bool
-xen_vbd_set_vdi(xen_session *session, xen_vbd vbd, xen_vdi vdi)
+xen_vbd_set_device(xen_session *session, xen_vbd vbd, char *device)
{
abstract_value param_values[] =
{
{ .type = &abstract_type_string,
.u.string_val = vbd },
{ .type = &abstract_type_string,
- .u.string_val = vdi }
+ .u.string_val = device }
};
- xen_call_(session, "VBD.set_VDI", param_values, 2, NULL, NULL);
+ xen_call_(session, "VBD.set_device", param_values, 2, NULL, NULL);
return session->ok;
}
bool
-xen_vbd_set_device(xen_session *session, xen_vbd vbd, char *device)
+xen_vbd_set_bootable(xen_session *session, xen_vbd vbd, bool bootable)
{
abstract_value param_values[] =
{
{ .type = &abstract_type_string,
.u.string_val = vbd },
- { .type = &abstract_type_string,
- .u.string_val = device }
+ { .type = &abstract_type_bool,
+ .u.bool_val = bootable }
};
- xen_call_(session, "VBD.set_device", param_values, 2, NULL, NULL);
+ xen_call_(session, "VBD.set_bootable", param_values, 2, NULL, NULL);
return session->ok;
}
@@ -348,22 +330,6 @@ xen_vbd_set_mode(xen_session *session, xen_vbd vbd, enum xen_vbd_mode mode)
bool
-xen_vbd_set_driver(xen_session *session, xen_vbd vbd, enum xen_driver_type driver)
-{
- abstract_value param_values[] =
- {
- { .type = &abstract_type_string,
- .u.string_val = vbd },
- { .type = &xen_driver_type_abstract_type_,
- .u.string_val = xen_driver_type_to_string(driver) }
- };
-
- xen_call_(session, "VBD.set_driver", param_values, 2, NULL, NULL);
- return session->ok;
-}
-
-
-bool
xen_vbd_media_change(xen_session *session, xen_vbd vbd, xen_vdi vdi)
{
abstract_value param_values[] =
diff --git a/tools/libxen/src/xen_vdi.c b/tools/libxen/src/xen_vdi.c
index a8d157d232..b2eddbcafb 100644
--- a/tools/libxen/src/xen_vdi.c
+++ b/tools/libxen/src/xen_vdi.c
@@ -21,6 +21,7 @@
#include <stdlib.h>
#include "xen_common.h"
+#include "xen_crashdump.h"
#include "xen_internal.h"
#include "xen_sr.h"
#include "xen_vbd.h"
@@ -54,6 +55,9 @@ static const struct_member xen_vdi_record_struct_members[] =
{ .key = "VBDs",
.type = &abstract_type_ref_set,
.offset = offsetof(xen_vdi_record, vbds) },
+ { .key = "crash_dumps",
+ .type = &abstract_type_ref_set,
+ .offset = offsetof(xen_vdi_record, crash_dumps) },
{ .key = "virtual_size",
.type = &abstract_type_int,
.offset = offsetof(xen_vdi_record, virtual_size) },
@@ -66,12 +70,6 @@ static const struct_member xen_vdi_record_struct_members[] =
{ .key = "type",
.type = &xen_vdi_type_abstract_type_,
.offset = offsetof(xen_vdi_record, type) },
- { .key = "parent",
- .type = &abstract_type_ref,
- .offset = offsetof(xen_vdi_record, parent) },
- { .key = "children",
- .type = &abstract_type_ref_set,
- .offset = offsetof(xen_vdi_record, children) },
{ .key = "sharable",
.type = &abstract_type_bool,
.offset = offsetof(xen_vdi_record, sharable) },
@@ -103,8 +101,7 @@ xen_vdi_record_free(xen_vdi_record *record)
free(record->name_description);
xen_sr_record_opt_free(record->sr);
xen_vbd_record_opt_set_free(record->vbds);
- xen_vdi_record_opt_free(record->parent);
- xen_vdi_record_opt_set_free(record->children);
+ xen_crashdump_record_opt_set_free(record->crash_dumps);
free(record);
}
@@ -266,7 +263,7 @@ xen_vdi_get_vbds(xen_session *session, struct xen_vbd_set **result, xen_vdi vdi)
bool
-xen_vdi_get_virtual_size(xen_session *session, int64_t *result, xen_vdi vdi)
+xen_vdi_get_crash_dumps(xen_session *session, struct xen_crashdump_set **result, xen_vdi vdi)
{
abstract_value param_values[] =
{
@@ -274,15 +271,16 @@ xen_vdi_get_virtual_size(xen_session *session, int64_t *result, xen_vdi vdi)
.u.string_val = vdi }
};
- abstract_type result_type = abstract_type_int;
+ abstract_type result_type = abstract_type_string_set;
- XEN_CALL_("VDI.get_virtual_size");
+ *result = NULL;
+ XEN_CALL_("VDI.get_crash_dumps");
return session->ok;
}
bool
-xen_vdi_get_physical_utilisation(xen_session *session, int64_t *result, xen_vdi vdi)
+xen_vdi_get_virtual_size(xen_session *session, int64_t *result, xen_vdi vdi)
{
abstract_value param_values[] =
{
@@ -292,13 +290,13 @@ xen_vdi_get_physical_utilisation(xen_session *session, int64_t *result, xen_vdi
abstract_type result_type = abstract_type_int;
- XEN_CALL_("VDI.get_physical_utilisation");
+ XEN_CALL_("VDI.get_virtual_size");
return session->ok;
}
bool
-xen_vdi_get_sector_size(xen_session *session, int64_t *result, xen_vdi vdi)
+xen_vdi_get_physical_utilisation(xen_session *session, int64_t *result, xen_vdi vdi)
{
abstract_value param_values[] =
{
@@ -308,30 +306,13 @@ xen_vdi_get_sector_size(xen_session *session, int64_t *result, xen_vdi vdi)
abstract_type result_type = abstract_type_int;
- XEN_CALL_("VDI.get_sector_size");
- return session->ok;
-}
-
-
-bool
-xen_vdi_get_type(xen_session *session, enum xen_vdi_type *result, xen_vdi vdi)
-{
- abstract_value param_values[] =
- {
- { .type = &abstract_type_string,
- .u.string_val = vdi }
- };
-
- abstract_type result_type = xen_vdi_type_abstract_type_;
- char *result_str = NULL;
- XEN_CALL_("VDI.get_type");
- *result = xen_vdi_type_from_string(session, result_str);
+ XEN_CALL_("VDI.get_physical_utilisation");
return session->ok;
}
bool
-xen_vdi_get_parent(xen_session *session, xen_vdi *result, xen_vdi vdi)
+xen_vdi_get_sector_size(xen_session *session, int64_t *result, xen_vdi vdi)
{
abstract_value param_values[] =
{
@@ -339,16 +320,15 @@ xen_vdi_get_parent(xen_session *session, xen_vdi *result, xen_vdi vdi)
.u.string_val = vdi }
};
- abstract_type result_type = abstract_type_string;
+ abstract_type result_type = abstract_type_int;
- *result = NULL;
- XEN_CALL_("VDI.get_parent");
+ XEN_CALL_("VDI.get_sector_size");
return session->ok;
}
bool
-xen_vdi_get_children(xen_session *session, struct xen_vdi_set **result, xen_vdi vdi)
+xen_vdi_get_type(xen_session *session, enum xen_vdi_type *result, xen_vdi vdi)
{
abstract_value param_values[] =
{
@@ -356,10 +336,8 @@ xen_vdi_get_children(xen_session *session, struct xen_vdi_set **result, xen_vdi
.u.string_val = vdi }
};
- abstract_type result_type = abstract_type_string_set;
-
- *result = NULL;
- XEN_CALL_("VDI.get_children");
+ abstract_type result_type = xen_vdi_type_abstract_type_;
+ XEN_CALL_("VDI.get_type");
return session->ok;
}
diff --git a/tools/libxen/src/xen_vdi_type.c b/tools/libxen/src/xen_vdi_type.c
index 90cfe8c820..79e855fa59 100644
--- a/tools/libxen/src/xen_vdi_type.c
+++ b/tools/libxen/src/xen_vdi_type.c
@@ -30,7 +30,9 @@ static const char *lookup_table[] =
{
"system",
"user",
- "ephemeral"
+ "ephemeral",
+ "suspend",
+ "crashdump"
};
diff --git a/tools/libxen/src/xen_vif.c b/tools/libxen/src/xen_vif.c
index 82b4a15b31..47ef4730f6 100644
--- a/tools/libxen/src/xen_vif.c
+++ b/tools/libxen/src/xen_vif.c
@@ -21,7 +21,6 @@
#include <stdlib.h>
#include "xen_common.h"
-#include "xen_driver_type_internal.h"
#include "xen_internal.h"
#include "xen_network.h"
#include "xen_vif.h"
@@ -42,12 +41,6 @@ static const struct_member xen_vif_record_struct_members[] =
{ .key = "uuid",
.type = &abstract_type_string,
.offset = offsetof(xen_vif_record, uuid) },
- { .key = "name",
- .type = &abstract_type_string,
- .offset = offsetof(xen_vif_record, name) },
- { .key = "type",
- .type = &xen_driver_type_abstract_type_,
- .offset = offsetof(xen_vif_record, type) },
{ .key = "device",
.type = &abstract_type_string,
.offset = offsetof(xen_vif_record, device) },
@@ -90,7 +83,6 @@ xen_vif_record_free(xen_vif_record *record)
}
free(record->handle);
free(record->uuid);
- free(record->name);
free(record->device);
xen_network_record_opt_free(record->network);
xen_vm_record_opt_free(record->vm);
@@ -171,38 +163,6 @@ xen_vif_destroy(xen_session *session, xen_vif vif)
bool
-xen_vif_get_name(xen_session *session, char **result, xen_vif vif)
-{
- abstract_value param_values[] =
- {
- { .type = &abstract_type_string,
- .u.string_val = vif }
- };
-
- abstract_type result_type = abstract_type_string;
-
- *result = NULL;
- XEN_CALL_("VIF.get_name");
- return session->ok;
-}
-
-
-bool
-xen_vif_get_type(xen_session *session, enum xen_driver_type *result, xen_vif vif)
-{
- abstract_value param_values[] =
- {
- { .type = &abstract_type_string,
- .u.string_val = vif }
- };
-
- abstract_type result_type = xen_driver_type_abstract_type_;
- XEN_CALL_("VIF.get_type");
- return session->ok;
-}
-
-
-bool
xen_vif_get_device(xen_session *session, char **result, xen_vif vif)
{
abstract_value param_values[] =
@@ -319,38 +279,6 @@ xen_vif_get_io_write_kbs(xen_session *session, double *result, xen_vif vif)
bool
-xen_vif_set_name(xen_session *session, xen_vif vif, char *name)
-{
- abstract_value param_values[] =
- {
- { .type = &abstract_type_string,
- .u.string_val = vif },
- { .type = &abstract_type_string,
- .u.string_val = name }
- };
-
- xen_call_(session, "VIF.set_name", param_values, 2, NULL, NULL);
- return session->ok;
-}
-
-
-bool
-xen_vif_set_type(xen_session *session, xen_vif vif, enum xen_driver_type type)
-{
- abstract_value param_values[] =
- {
- { .type = &abstract_type_string,
- .u.string_val = vif },
- { .type = &xen_driver_type_abstract_type_,
- .u.string_val = xen_driver_type_to_string(type) }
- };
-
- xen_call_(session, "VIF.set_type", param_values, 2, NULL, NULL);
- return session->ok;
-}
-
-
-bool
xen_vif_set_device(xen_session *session, xen_vif vif, char *device)
{
abstract_value param_values[] =
@@ -367,38 +295,6 @@ xen_vif_set_device(xen_session *session, xen_vif vif, char *device)
bool
-xen_vif_set_network(xen_session *session, xen_vif vif, xen_network network)
-{
- abstract_value param_values[] =
- {
- { .type = &abstract_type_string,
- .u.string_val = vif },
- { .type = &abstract_type_string,
- .u.string_val = network }
- };
-
- xen_call_(session, "VIF.set_network", param_values, 2, NULL, NULL);
- return session->ok;
-}
-
-
-bool
-xen_vif_set_vm(xen_session *session, xen_vif vif, xen_vm vm)
-{
- abstract_value param_values[] =
- {
- { .type = &abstract_type_string,
- .u.string_val = vif },
- { .type = &abstract_type_string,
- .u.string_val = vm }
- };
-
- xen_call_(session, "VIF.set_VM", param_values, 2, NULL, NULL);
- return session->ok;
-}
-
-
-bool
xen_vif_set_mac(xen_session *session, xen_vif vif, char *mac)
{
abstract_value param_values[] =
diff --git a/tools/libxen/src/xen_vm.c b/tools/libxen/src/xen_vm.c
index 35cf104abf..6cbc3670b0 100644
--- a/tools/libxen/src/xen_vm.c
+++ b/tools/libxen/src/xen_vm.c
@@ -22,8 +22,7 @@
#include "xen_common.h"
#include "xen_console.h"
-#include "xen_cpu_feature.h"
-#include "xen_cpu_feature_internal.h"
+#include "xen_crashdump.h"
#include "xen_host.h"
#include "xen_int_float_map.h"
#include "xen_internal.h"
@@ -31,8 +30,10 @@
#include "xen_on_normal_exit_internal.h"
#include "xen_string_string_map.h"
#include "xen_vbd.h"
+#include "xen_vdi.h"
#include "xen_vif.h"
#include "xen_vm.h"
+#include "xen_vm_metrics.h"
#include "xen_vm_power_state_internal.h"
#include "xen_vtpm.h"
@@ -69,6 +70,9 @@ static const struct_member xen_vm_record_struct_members[] =
{ .key = "auto_power_on",
.type = &abstract_type_bool,
.offset = offsetof(xen_vm_record, auto_power_on) },
+ { .key = "suspend_VDI",
+ .type = &abstract_type_ref,
+ .offset = offsetof(xen_vm_record, suspend_vdi) },
{ .key = "resident_on",
.type = &abstract_type_ref,
.offset = offsetof(xen_vm_record, resident_on) },
@@ -78,9 +82,6 @@ static const struct_member xen_vm_record_struct_members[] =
{ .key = "memory_dynamic_max",
.type = &abstract_type_int,
.offset = offsetof(xen_vm_record, memory_dynamic_max) },
- { .key = "memory_actual",
- .type = &abstract_type_int,
- .offset = offsetof(xen_vm_record, memory_actual) },
{ .key = "memory_dynamic_min",
.type = &abstract_type_int,
.offset = offsetof(xen_vm_record, memory_dynamic_min) },
@@ -91,35 +92,26 @@ static const struct_member xen_vm_record_struct_members[] =
.type = &abstract_type_string,
.offset = offsetof(xen_vm_record, vcpus_policy) },
{ .key = "VCPUs_params",
- .type = &abstract_type_string,
+ .type = &abstract_type_string_string_map,
.offset = offsetof(xen_vm_record, vcpus_params) },
+ { .key = "VCPUs_max",
+ .type = &abstract_type_int,
+ .offset = offsetof(xen_vm_record, vcpus_max) },
+ { .key = "VCPUs_at_startup",
+ .type = &abstract_type_int,
+ .offset = offsetof(xen_vm_record, vcpus_at_startup) },
{ .key = "VCPUs_number",
.type = &abstract_type_int,
.offset = offsetof(xen_vm_record, vcpus_number) },
{ .key = "VCPUs_utilisation",
.type = &abstract_type_int_float_map,
.offset = offsetof(xen_vm_record, vcpus_utilisation) },
- { .key = "VCPUs_features_required",
- .type = &xen_cpu_feature_set_abstract_type_,
- .offset = offsetof(xen_vm_record, vcpus_features_required) },
- { .key = "VCPUs_features_can_use",
- .type = &xen_cpu_feature_set_abstract_type_,
- .offset = offsetof(xen_vm_record, vcpus_features_can_use) },
- { .key = "VCPUs_features_force_on",
- .type = &xen_cpu_feature_set_abstract_type_,
- .offset = offsetof(xen_vm_record, vcpus_features_force_on) },
- { .key = "VCPUs_features_force_off",
- .type = &xen_cpu_feature_set_abstract_type_,
- .offset = offsetof(xen_vm_record, vcpus_features_force_off) },
{ .key = "actions_after_shutdown",
.type = &xen_on_normal_exit_abstract_type_,
.offset = offsetof(xen_vm_record, actions_after_shutdown) },
{ .key = "actions_after_reboot",
.type = &xen_on_normal_exit_abstract_type_,
.offset = offsetof(xen_vm_record, actions_after_reboot) },
- { .key = "actions_after_suspend",
- .type = &xen_on_normal_exit_abstract_type_,
- .offset = offsetof(xen_vm_record, actions_after_suspend) },
{ .key = "actions_after_crash",
.type = &xen_on_crash_behaviour_abstract_type_,
.offset = offsetof(xen_vm_record, actions_after_crash) },
@@ -132,6 +124,9 @@ static const struct_member xen_vm_record_struct_members[] =
{ .key = "VBDs",
.type = &abstract_type_ref_set,
.offset = offsetof(xen_vm_record, vbds) },
+ { .key = "crash_dumps",
+ .type = &abstract_type_ref_set,
+ .offset = offsetof(xen_vm_record, crash_dumps) },
{ .key = "VTPMs",
.type = &abstract_type_ref_set,
.offset = offsetof(xen_vm_record, vtpms) },
@@ -174,9 +169,15 @@ static const struct_member xen_vm_record_struct_members[] =
{ .key = "tools_version",
.type = &abstract_type_string_string_map,
.offset = offsetof(xen_vm_record, tools_version) },
- { .key = "otherConfig",
+ { .key = "other_config",
.type = &abstract_type_string_string_map,
- .offset = offsetof(xen_vm_record, otherconfig) }
+ .offset = offsetof(xen_vm_record, other_config) },
+ { .key = "is_control_domain",
+ .type = &abstract_type_bool,
+ .offset = offsetof(xen_vm_record, is_control_domain) },
+ { .key = "metrics",
+ .type = &abstract_type_ref,
+ .offset = offsetof(xen_vm_record, metrics) }
};
const abstract_type xen_vm_record_abstract_type_ =
@@ -200,17 +201,15 @@ xen_vm_record_free(xen_vm_record *record)
free(record->uuid);
free(record->name_label);
free(record->name_description);
+ xen_vdi_record_opt_free(record->suspend_vdi);
xen_host_record_opt_free(record->resident_on);
free(record->vcpus_policy);
- free(record->vcpus_params);
+ xen_string_string_map_free(record->vcpus_params);
xen_int_float_map_free(record->vcpus_utilisation);
- xen_cpu_feature_set_free(record->vcpus_features_required);
- xen_cpu_feature_set_free(record->vcpus_features_can_use);
- xen_cpu_feature_set_free(record->vcpus_features_force_on);
- xen_cpu_feature_set_free(record->vcpus_features_force_off);
xen_console_record_opt_set_free(record->consoles);
xen_vif_record_opt_set_free(record->vifs);
xen_vbd_record_opt_set_free(record->vbds);
+ xen_crashdump_record_opt_set_free(record->crash_dumps);
xen_vtpm_record_opt_set_free(record->vtpms);
free(record->pv_bootloader);
free(record->pv_kernel);
@@ -221,7 +220,8 @@ xen_vm_record_free(xen_vm_record *record)
free(record->platform_serial);
free(record->pci_bus);
xen_string_string_map_free(record->tools_version);
- xen_string_string_map_free(record->otherconfig);
+ xen_string_string_map_free(record->other_config);
+ xen_vm_metrics_record_opt_free(record->metrics);
free(record);
}
@@ -412,7 +412,7 @@ xen_vm_get_auto_power_on(xen_session *session, bool *result, xen_vm vm)
bool
-xen_vm_get_resident_on(xen_session *session, xen_host *result, xen_vm vm)
+xen_vm_get_suspend_vdi(xen_session *session, xen_vdi *result, xen_vm vm)
{
abstract_value param_values[] =
{
@@ -423,13 +423,13 @@ xen_vm_get_resident_on(xen_session *session, xen_host *result, xen_vm vm)
abstract_type result_type = abstract_type_string;
*result = NULL;
- XEN_CALL_("VM.get_resident_on");
+ XEN_CALL_("VM.get_suspend_VDI");
return session->ok;
}
bool
-xen_vm_get_memory_static_max(xen_session *session, int64_t *result, xen_vm vm)
+xen_vm_get_resident_on(xen_session *session, xen_host *result, xen_vm vm)
{
abstract_value param_values[] =
{
@@ -437,15 +437,16 @@ xen_vm_get_memory_static_max(xen_session *session, int64_t *result, xen_vm vm)
.u.string_val = vm }
};
- abstract_type result_type = abstract_type_int;
+ abstract_type result_type = abstract_type_string;
- XEN_CALL_("VM.get_memory_static_max");
+ *result = NULL;
+ XEN_CALL_("VM.get_resident_on");
return session->ok;
}
bool
-xen_vm_get_memory_dynamic_max(xen_session *session, int64_t *result, xen_vm vm)
+xen_vm_get_memory_static_max(xen_session *session, int64_t *result, xen_vm vm)
{
abstract_value param_values[] =
{
@@ -455,13 +456,13 @@ xen_vm_get_memory_dynamic_max(xen_session *session, int64_t *result, xen_vm vm)
abstract_type result_type = abstract_type_int;
- XEN_CALL_("VM.get_memory_dynamic_max");
+ XEN_CALL_("VM.get_memory_static_max");
return session->ok;
}
bool
-xen_vm_get_memory_actual(xen_session *session, int64_t *result, xen_vm vm)
+xen_vm_get_memory_dynamic_max(xen_session *session, int64_t *result, xen_vm vm)
{
abstract_value param_values[] =
{
@@ -471,7 +472,7 @@ xen_vm_get_memory_actual(xen_session *session, int64_t *result, xen_vm vm)
abstract_type result_type = abstract_type_int;
- XEN_CALL_("VM.get_memory_actual");
+ XEN_CALL_("VM.get_memory_dynamic_max");
return session->ok;
}
@@ -526,7 +527,7 @@ xen_vm_get_vcpus_policy(xen_session *session, char **result, xen_vm vm)
bool
-xen_vm_get_vcpus_params(xen_session *session, char **result, xen_vm vm)
+xen_vm_get_vcpus_params(xen_session *session, xen_string_string_map **result, xen_vm vm)
{
abstract_value param_values[] =
{
@@ -534,7 +535,7 @@ xen_vm_get_vcpus_params(xen_session *session, char **result, xen_vm vm)
.u.string_val = vm }
};
- abstract_type result_type = abstract_type_string;
+ abstract_type result_type = abstract_type_string_string_map;
*result = NULL;
XEN_CALL_("VM.get_VCPUs_params");
@@ -543,7 +544,7 @@ xen_vm_get_vcpus_params(xen_session *session, char **result, xen_vm vm)
bool
-xen_vm_get_vcpus_number(xen_session *session, int64_t *result, xen_vm vm)
+xen_vm_get_vcpus_max(xen_session *session, int64_t *result, xen_vm vm)
{
abstract_value param_values[] =
{
@@ -553,13 +554,13 @@ xen_vm_get_vcpus_number(xen_session *session, int64_t *result, xen_vm vm)
abstract_type result_type = abstract_type_int;
- XEN_CALL_("VM.get_VCPUs_number");
+ XEN_CALL_("VM.get_VCPUs_max");
return session->ok;
}
bool
-xen_vm_get_vcpus_utilisation(xen_session *session, xen_int_float_map **result, xen_vm vm)
+xen_vm_get_vcpus_at_startup(xen_session *session, int64_t *result, xen_vm vm)
{
abstract_value param_values[] =
{
@@ -567,50 +568,15 @@ xen_vm_get_vcpus_utilisation(xen_session *session, xen_int_float_map **result, x
.u.string_val = vm }
};
- abstract_type result_type = abstract_type_int_float_map;
-
- *result = NULL;
- XEN_CALL_("VM.get_VCPUs_utilisation");
- return session->ok;
-}
-
-
-bool
-xen_vm_get_vcpus_features_required(xen_session *session, struct xen_cpu_feature_set **result, xen_vm vm)
-{
- abstract_value param_values[] =
- {
- { .type = &abstract_type_string,
- .u.string_val = vm }
- };
-
- abstract_type result_type = xen_cpu_feature_set_abstract_type_;
-
- *result = NULL;
- XEN_CALL_("VM.get_VCPUs_features_required");
- return session->ok;
-}
-
-
-bool
-xen_vm_get_vcpus_features_can_use(xen_session *session, struct xen_cpu_feature_set **result, xen_vm vm)
-{
- abstract_value param_values[] =
- {
- { .type = &abstract_type_string,
- .u.string_val = vm }
- };
-
- abstract_type result_type = xen_cpu_feature_set_abstract_type_;
+ abstract_type result_type = abstract_type_int;
- *result = NULL;
- XEN_CALL_("VM.get_VCPUs_features_can_use");
+ XEN_CALL_("VM.get_VCPUs_at_startup");
return session->ok;
}
bool
-xen_vm_get_vcpus_features_force_on(xen_session *session, struct xen_cpu_feature_set **result, xen_vm vm)
+xen_vm_get_vcpus_number(xen_session *session, int64_t *result, xen_vm vm)
{
abstract_value param_values[] =
{
@@ -618,16 +584,15 @@ xen_vm_get_vcpus_features_force_on(xen_session *session, struct xen_cpu_feature_
.u.string_val = vm }
};
- abstract_type result_type = xen_cpu_feature_set_abstract_type_;
+ abstract_type result_type = abstract_type_int;
- *result = NULL;
- XEN_CALL_("VM.get_VCPUs_features_force_on");
+ XEN_CALL_("VM.get_VCPUs_number");
return session->ok;
}
bool
-xen_vm_get_vcpus_features_force_off(xen_session *session, struct xen_cpu_feature_set **result, xen_vm vm)
+xen_vm_get_vcpus_utilisation(xen_session *session, xen_int_float_map **result, xen_vm vm)
{
abstract_value param_values[] =
{
@@ -635,10 +600,10 @@ xen_vm_get_vcpus_features_force_off(xen_session *session, struct xen_cpu_feature
.u.string_val = vm }
};
- abstract_type result_type = xen_cpu_feature_set_abstract_type_;
+ abstract_type result_type = abstract_type_int_float_map;
*result = NULL;
- XEN_CALL_("VM.get_VCPUs_features_force_off");
+ XEN_CALL_("VM.get_VCPUs_utilisation");
return session->ok;
}
@@ -674,7 +639,7 @@ xen_vm_get_actions_after_reboot(xen_session *session, enum xen_on_normal_exit *r
bool
-xen_vm_get_actions_after_suspend(xen_session *session, enum xen_on_normal_exit *result, xen_vm vm)
+xen_vm_get_actions_after_crash(xen_session *session, enum xen_on_crash_behaviour *result, xen_vm vm)
{
abstract_value param_values[] =
{
@@ -682,14 +647,14 @@ xen_vm_get_actions_after_suspend(xen_session *session, enum xen_on_normal_exit *
.u.string_val = vm }
};
- abstract_type result_type = xen_on_normal_exit_abstract_type_;
- XEN_CALL_("VM.get_actions_after_suspend");
+ abstract_type result_type = xen_on_crash_behaviour_abstract_type_;
+ XEN_CALL_("VM.get_actions_after_crash");
return session->ok;
}
bool
-xen_vm_get_actions_after_crash(xen_session *session, enum xen_on_crash_behaviour *result, xen_vm vm)
+xen_vm_get_consoles(xen_session *session, struct xen_console_set **result, xen_vm vm)
{
abstract_value param_values[] =
{
@@ -697,14 +662,16 @@ xen_vm_get_actions_after_crash(xen_session *session, enum xen_on_crash_behaviour
.u.string_val = vm }
};
- abstract_type result_type = xen_on_crash_behaviour_abstract_type_;
- XEN_CALL_("VM.get_actions_after_crash");
+ abstract_type result_type = abstract_type_string_set;
+
+ *result = NULL;
+ XEN_CALL_("VM.get_consoles");
return session->ok;
}
bool
-xen_vm_get_consoles(xen_session *session, struct xen_console_set **result, xen_vm vm)
+xen_vm_get_vifs(xen_session *session, struct xen_vif_set **result, xen_vm vm)
{
abstract_value param_values[] =
{
@@ -715,13 +682,13 @@ xen_vm_get_consoles(xen_session *session, struct xen_console_set **result, xen_v
abstract_type result_type = abstract_type_string_set;
*result = NULL;
- XEN_CALL_("VM.get_consoles");
+ XEN_CALL_("VM.get_VIFs");
return session->ok;
}
bool
-xen_vm_get_vifs(xen_session *session, struct xen_vif_set **result, xen_vm vm)
+xen_vm_get_vbds(xen_session *session, struct xen_vbd_set **result, xen_vm vm)
{
abstract_value param_values[] =
{
@@ -732,13 +699,13 @@ xen_vm_get_vifs(xen_session *session, struct xen_vif_set **result, xen_vm vm)
abstract_type result_type = abstract_type_string_set;
*result = NULL;
- XEN_CALL_("VM.get_VIFs");
+ XEN_CALL_("VM.get_VBDs");
return session->ok;
}
bool
-xen_vm_get_vbds(xen_session *session, struct xen_vbd_set **result, xen_vm vm)
+xen_vm_get_crash_dumps(xen_session *session, struct xen_crashdump_set **result, xen_vm vm)
{
abstract_value param_values[] =
{
@@ -749,7 +716,7 @@ xen_vm_get_vbds(xen_session *session, struct xen_vbd_set **result, xen_vm vm)
abstract_type result_type = abstract_type_string_set;
*result = NULL;
- XEN_CALL_("VM.get_VBDs");
+ XEN_CALL_("VM.get_crash_dumps");
return session->ok;
}
@@ -989,7 +956,7 @@ xen_vm_get_tools_version(xen_session *session, xen_string_string_map **result, x
bool
-xen_vm_get_otherconfig(xen_session *session, xen_string_string_map **result, xen_vm vm)
+xen_vm_get_other_config(xen_session *session, xen_string_string_map **result, xen_vm vm)
{
abstract_value param_values[] =
{
@@ -1000,7 +967,40 @@ xen_vm_get_otherconfig(xen_session *session, xen_string_string_map **result, xen
abstract_type result_type = abstract_type_string_string_map;
*result = NULL;
- XEN_CALL_("VM.get_otherConfig");
+ XEN_CALL_("VM.get_other_config");
+ return session->ok;
+}
+
+
+bool
+xen_vm_get_is_control_domain(xen_session *session, bool *result, xen_vm vm)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = vm }
+ };
+
+ abstract_type result_type = abstract_type_bool;
+
+ XEN_CALL_("VM.get_is_control_domain");
+ return session->ok;
+}
+
+
+bool
+xen_vm_get_metrics(xen_session *session, xen_vm_metrics *result, xen_vm vm)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = vm }
+ };
+
+ abstract_type result_type = abstract_type_string;
+
+ *result = NULL;
+ XEN_CALL_("VM.get_metrics");
return session->ok;
}
@@ -1086,177 +1086,163 @@ xen_vm_set_auto_power_on(xen_session *session, xen_vm vm, bool auto_power_on)
bool
-xen_vm_set_memory_dynamic_max(xen_session *session, xen_vm vm, int64_t dynamic_max)
+xen_vm_set_memory_static_max(xen_session *session, xen_vm vm, int64_t static_max)
{
abstract_value param_values[] =
{
{ .type = &abstract_type_string,
.u.string_val = vm },
{ .type = &abstract_type_int,
- .u.int_val = dynamic_max }
+ .u.int_val = static_max }
};
- xen_call_(session, "VM.set_memory_dynamic_max", param_values, 2, NULL, NULL);
+ xen_call_(session, "VM.set_memory_static_max", param_values, 2, NULL, NULL);
return session->ok;
}
bool
-xen_vm_set_memory_dynamic_min(xen_session *session, xen_vm vm, int64_t dynamic_min)
+xen_vm_set_memory_dynamic_max(xen_session *session, xen_vm vm, int64_t dynamic_max)
{
abstract_value param_values[] =
{
{ .type = &abstract_type_string,
.u.string_val = vm },
{ .type = &abstract_type_int,
- .u.int_val = dynamic_min }
- };
-
- xen_call_(session, "VM.set_memory_dynamic_min", param_values, 2, NULL, NULL);
- return session->ok;
-}
-
-
-bool
-xen_vm_set_vcpus_policy(xen_session *session, xen_vm vm, char *policy)
-{
- abstract_value param_values[] =
- {
- { .type = &abstract_type_string,
- .u.string_val = vm },
- { .type = &abstract_type_string,
- .u.string_val = policy }
+ .u.int_val = dynamic_max }
};
- xen_call_(session, "VM.set_VCPUs_policy", param_values, 2, NULL, NULL);
+ xen_call_(session, "VM.set_memory_dynamic_max", param_values, 2, NULL, NULL);
return session->ok;
}
bool
-xen_vm_set_vcpus_params(xen_session *session, xen_vm vm, char *params)
+xen_vm_set_memory_dynamic_min(xen_session *session, xen_vm vm, int64_t dynamic_min)
{
abstract_value param_values[] =
{
{ .type = &abstract_type_string,
.u.string_val = vm },
- { .type = &abstract_type_string,
- .u.string_val = params }
+ { .type = &abstract_type_int,
+ .u.int_val = dynamic_min }
};
- xen_call_(session, "VM.set_VCPUs_params", param_values, 2, NULL, NULL);
+ xen_call_(session, "VM.set_memory_dynamic_min", param_values, 2, NULL, NULL);
return session->ok;
}
bool
-xen_vm_set_vcpus_number(xen_session *session, xen_vm vm, int64_t number)
+xen_vm_set_memory_static_min(xen_session *session, xen_vm vm, int64_t static_min)
{
abstract_value param_values[] =
{
{ .type = &abstract_type_string,
.u.string_val = vm },
{ .type = &abstract_type_int,
- .u.int_val = number }
+ .u.int_val = static_min }
};
- xen_call_(session, "VM.set_VCPUs_number", param_values, 2, NULL, NULL);
+ xen_call_(session, "VM.set_memory_static_min", param_values, 2, NULL, NULL);
return session->ok;
}
bool
-xen_vm_set_vcpus_features_force_on(xen_session *session, xen_vm vm, struct xen_cpu_feature_set *force_on)
+xen_vm_set_vcpus_policy(xen_session *session, xen_vm vm, char *policy)
{
abstract_value param_values[] =
{
{ .type = &abstract_type_string,
.u.string_val = vm },
- { .type = &xen_cpu_feature_set_abstract_type_,
- .u.set_val = (arbitrary_set *)force_on }
+ { .type = &abstract_type_string,
+ .u.string_val = policy }
};
- xen_call_(session, "VM.set_VCPUs_features_force_on", param_values, 2, NULL, NULL);
+ xen_call_(session, "VM.set_VCPUs_policy", param_values, 2, NULL, NULL);
return session->ok;
}
bool
-xen_vm_add_vcpus_features_force_on(xen_session *session, xen_vm vm, enum xen_cpu_feature value)
+xen_vm_set_vcpus_params(xen_session *session, xen_vm vm, xen_string_string_map *params)
{
abstract_value param_values[] =
{
{ .type = &abstract_type_string,
.u.string_val = vm },
- { .type = &xen_cpu_feature_abstract_type_,
- .u.string_val = xen_cpu_feature_to_string(value) }
+ { .type = &abstract_type_string_string_map,
+ .u.set_val = (arbitrary_set *)params }
};
- xen_call_(session, "VM.add_VCPUs_features_force_on", param_values, 2, NULL, NULL);
+ xen_call_(session, "VM.set_VCPUs_params", param_values, 2, NULL, NULL);
return session->ok;
}
bool
-xen_vm_remove_vcpus_features_force_on(xen_session *session, xen_vm vm, enum xen_cpu_feature value)
+xen_vm_add_to_vcpus_params(xen_session *session, xen_vm vm, char *key, char *value)
{
abstract_value param_values[] =
{
{ .type = &abstract_type_string,
.u.string_val = vm },
- { .type = &xen_cpu_feature_abstract_type_,
- .u.string_val = xen_cpu_feature_to_string(value) }
+ { .type = &abstract_type_string,
+ .u.string_val = key },
+ { .type = &abstract_type_string,
+ .u.string_val = value }
};
- xen_call_(session, "VM.remove_VCPUs_features_force_on", param_values, 2, NULL, NULL);
+ xen_call_(session, "VM.add_to_VCPUs_params", param_values, 3, NULL, NULL);
return session->ok;
}
bool
-xen_vm_set_vcpus_features_force_off(xen_session *session, xen_vm vm, struct xen_cpu_feature_set *force_off)
+xen_vm_remove_from_vcpus_params(xen_session *session, xen_vm vm, char *key)
{
abstract_value param_values[] =
{
{ .type = &abstract_type_string,
.u.string_val = vm },
- { .type = &xen_cpu_feature_set_abstract_type_,
- .u.set_val = (arbitrary_set *)force_off }
+ { .type = &abstract_type_string,
+ .u.string_val = key }
};
- xen_call_(session, "VM.set_VCPUs_features_force_off", param_values, 2, NULL, NULL);
+ xen_call_(session, "VM.remove_from_VCPUs_params", param_values, 2, NULL, NULL);
return session->ok;
}
bool
-xen_vm_add_vcpus_features_force_off(xen_session *session, xen_vm vm, enum xen_cpu_feature value)
+xen_vm_set_vcpus_max(xen_session *session, xen_vm vm, int64_t max)
{
abstract_value param_values[] =
{
{ .type = &abstract_type_string,
.u.string_val = vm },
- { .type = &xen_cpu_feature_abstract_type_,
- .u.string_val = xen_cpu_feature_to_string(value) }
+ { .type = &abstract_type_int,
+ .u.int_val = max }
};
- xen_call_(session, "VM.add_VCPUs_features_force_off", param_values, 2, NULL, NULL);
+ xen_call_(session, "VM.set_VCPUs_max", param_values, 2, NULL, NULL);
return session->ok;
}
bool
-xen_vm_remove_vcpus_features_force_off(xen_session *session, xen_vm vm, enum xen_cpu_feature value)
+xen_vm_set_vcpus_at_startup(xen_session *session, xen_vm vm, int64_t at_startup)
{
abstract_value param_values[] =
{
{ .type = &abstract_type_string,
.u.string_val = vm },
- { .type = &xen_cpu_feature_abstract_type_,
- .u.string_val = xen_cpu_feature_to_string(value) }
+ { .type = &abstract_type_int,
+ .u.int_val = at_startup }
};
- xen_call_(session, "VM.remove_VCPUs_features_force_off", param_values, 2, NULL, NULL);
+ xen_call_(session, "VM.set_VCPUs_at_startup", param_values, 2, NULL, NULL);
return session->ok;
}
@@ -1294,22 +1280,6 @@ xen_vm_set_actions_after_reboot(xen_session *session, xen_vm vm, enum xen_on_nor
bool
-xen_vm_set_actions_after_suspend(xen_session *session, xen_vm vm, enum xen_on_normal_exit after_suspend)
-{
- abstract_value param_values[] =
- {
- { .type = &abstract_type_string,
- .u.string_val = vm },
- { .type = &xen_on_normal_exit_abstract_type_,
- .u.string_val = xen_on_normal_exit_to_string(after_suspend) }
- };
-
- xen_call_(session, "VM.set_actions_after_suspend", param_values, 2, NULL, NULL);
- return session->ok;
-}
-
-
-bool
xen_vm_set_actions_after_crash(xen_session *session, xen_vm vm, enum xen_on_crash_behaviour after_crash)
{
abstract_value param_values[] =
@@ -1502,17 +1472,51 @@ xen_vm_set_platform_enable_audio(xen_session *session, xen_vm vm, bool enable_au
bool
-xen_vm_set_otherconfig(xen_session *session, xen_vm vm, xen_string_string_map *otherconfig)
+xen_vm_set_other_config(xen_session *session, xen_vm vm, xen_string_string_map *other_config)
{
abstract_value param_values[] =
{
{ .type = &abstract_type_string,
.u.string_val = vm },
{ .type = &abstract_type_string_string_map,
- .u.set_val = (arbitrary_set *)otherconfig }
+ .u.set_val = (arbitrary_set *)other_config }
+ };
+
+ xen_call_(session, "VM.set_other_config", param_values, 2, NULL, NULL);
+ return session->ok;
+}
+
+
+bool
+xen_vm_add_to_other_config(xen_session *session, xen_vm vm, char *key, char *value)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = vm },
+ { .type = &abstract_type_string,
+ .u.string_val = key },
+ { .type = &abstract_type_string,
+ .u.string_val = value }
+ };
+
+ xen_call_(session, "VM.add_to_other_config", param_values, 3, NULL, NULL);
+ return session->ok;
+}
+
+
+bool
+xen_vm_remove_from_other_config(xen_session *session, xen_vm vm, char *key)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = vm },
+ { .type = &abstract_type_string,
+ .u.string_val = key }
};
- xen_call_(session, "VM.set_otherConfig", param_values, 2, NULL, NULL);
+ xen_call_(session, "VM.remove_from_other_config", param_values, 2, NULL, NULL);
return session->ok;
}
diff --git a/tools/libxen/src/xen_vm_metrics.c b/tools/libxen/src/xen_vm_metrics.c
new file mode 100644
index 0000000000..03a08d8971
--- /dev/null
+++ b/tools/libxen/src/xen_vm_metrics.c
@@ -0,0 +1,194 @@
+/*
+ * Copyright (c) 2006, XenSource Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+
+#include <stddef.h>
+#include <stdlib.h>
+
+#include "xen_common.h"
+#include "xen_int_float_map.h"
+#include "xen_internal.h"
+#include "xen_vm.h"
+#include "xen_vm_metrics.h"
+
+
+XEN_FREE(xen_vm_metrics)
+XEN_SET_ALLOC_FREE(xen_vm_metrics)
+XEN_ALLOC(xen_vm_metrics_record)
+XEN_SET_ALLOC_FREE(xen_vm_metrics_record)
+XEN_ALLOC(xen_vm_metrics_record_opt)
+XEN_RECORD_OPT_FREE(xen_vm_metrics)
+XEN_SET_ALLOC_FREE(xen_vm_metrics_record_opt)
+
+
+static const struct_member xen_vm_metrics_record_struct_members[] =
+ {
+ { .key = "uuid",
+ .type = &abstract_type_string,
+ .offset = offsetof(xen_vm_metrics_record, uuid) },
+ { .key = "VM",
+ .type = &abstract_type_ref,
+ .offset = offsetof(xen_vm_metrics_record, vm) },
+ { .key = "memory_actual",
+ .type = &abstract_type_int,
+ .offset = offsetof(xen_vm_metrics_record, memory_actual) },
+ { .key = "VCPUs_number",
+ .type = &abstract_type_int,
+ .offset = offsetof(xen_vm_metrics_record, vcpus_number) },
+ { .key = "VCPUs_utilisation",
+ .type = &abstract_type_int_float_map,
+ .offset = offsetof(xen_vm_metrics_record, vcpus_utilisation) }
+ };
+
+const abstract_type xen_vm_metrics_record_abstract_type_ =
+ {
+ .typename = STRUCT,
+ .struct_size = sizeof(xen_vm_metrics_record),
+ .member_count =
+ sizeof(xen_vm_metrics_record_struct_members) / sizeof(struct_member),
+ .members = xen_vm_metrics_record_struct_members
+ };
+
+
+void
+xen_vm_metrics_record_free(xen_vm_metrics_record *record)
+{
+ if (record == NULL)
+ {
+ return;
+ }
+ free(record->handle);
+ free(record->uuid);
+ xen_vm_record_opt_free(record->vm);
+ xen_int_float_map_free(record->vcpus_utilisation);
+ free(record);
+}
+
+
+bool
+xen_vm_metrics_get_record(xen_session *session, xen_vm_metrics_record **result, xen_vm_metrics vm_metrics)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = vm_metrics }
+ };
+
+ abstract_type result_type = xen_vm_metrics_record_abstract_type_;
+
+ *result = NULL;
+ XEN_CALL_("VM_metrics.get_record");
+
+ if (session->ok)
+ {
+ (*result)->handle = xen_strdup_((*result)->uuid);
+ }
+
+ return session->ok;
+}
+
+
+bool
+xen_vm_metrics_get_by_uuid(xen_session *session, xen_vm_metrics *result, char *uuid)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = uuid }
+ };
+
+ abstract_type result_type = abstract_type_string;
+
+ *result = NULL;
+ XEN_CALL_("VM_metrics.get_by_uuid");
+ return session->ok;
+}
+
+
+bool
+xen_vm_metrics_get_vm(xen_session *session, xen_vm *result, xen_vm_metrics vm_metrics)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = vm_metrics }
+ };
+
+ abstract_type result_type = abstract_type_string;
+
+ *result = NULL;
+ XEN_CALL_("VM_metrics.get_VM");
+ return session->ok;
+}
+
+
+bool
+xen_vm_metrics_get_memory_actual(xen_session *session, int64_t *result, xen_vm_metrics vm_metrics)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = vm_metrics }
+ };
+
+ abstract_type result_type = abstract_type_int;
+
+ XEN_CALL_("VM_metrics.get_memory_actual");
+ return session->ok;
+}
+
+
+bool
+xen_vm_metrics_get_vcpus_number(xen_session *session, int64_t *result, xen_vm_metrics vm_metrics)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = vm_metrics }
+ };
+
+ abstract_type result_type = abstract_type_int;
+
+ XEN_CALL_("VM_metrics.get_VCPUs_number");
+ return session->ok;
+}
+
+
+bool
+xen_vm_metrics_get_vcpus_utilisation(xen_session *session, xen_int_float_map **result, xen_vm_metrics vm_metrics)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = vm_metrics }
+ };
+
+ abstract_type result_type = abstract_type_int_float_map;
+
+ *result = NULL;
+ XEN_CALL_("VM_metrics.get_VCPUs_utilisation");
+ return session->ok;
+}
+
+
+bool
+xen_vm_metrics_get_uuid(xen_session *session, char **result, xen_vm_metrics vm_metrics)
+{
+ *result = session->ok ? xen_strdup_((char *)vm_metrics) : NULL;
+ return session->ok;
+}
diff --git a/tools/libxen/src/xen_vtpm.c b/tools/libxen/src/xen_vtpm.c
index 7c482be459..2b695f6ee2 100644
--- a/tools/libxen/src/xen_vtpm.c
+++ b/tools/libxen/src/xen_vtpm.c
@@ -22,7 +22,6 @@
#include <stdlib.h>
#include "xen_common.h"
-#include "xen_driver_type_internal.h"
#include "xen_internal.h"
#include "xen_vm.h"
#include "xen_vtpm.h"
@@ -48,12 +47,6 @@ static const struct_member xen_vtpm_record_struct_members[] =
{ .key = "backend",
.type = &abstract_type_ref,
.offset = offsetof(xen_vtpm_record, backend) },
- { .key = "driver",
- .type = &xen_driver_type_abstract_type_,
- .offset = offsetof(xen_vtpm_record, driver) },
- { .key = "instance",
- .type = &abstract_type_int,
- .offset = offsetof(xen_vtpm_record, instance) }
};
const abstract_type xen_vtpm_record_abstract_type_ =
@@ -187,37 +180,6 @@ xen_vtpm_get_backend(xen_session *session, xen_vm *result, xen_vtpm vtpm)
bool
-xen_vtpm_get_driver(xen_session *session, enum xen_driver_type *result, xen_vtpm vtpm)
-{
- abstract_value param_values[] =
- {
- { .type = &abstract_type_string,
- .u.string_val = vtpm }
- };
-
- abstract_type result_type = xen_driver_type_abstract_type_;
- XEN_CALL_("VTPM.get_driver");
- return session->ok;
-}
-
-
-bool
-xen_vtpm_get_instance(xen_session *session, int64_t *result, xen_vtpm vtpm)
-{
- abstract_value param_values[] =
- {
- { .type = &abstract_type_string,
- .u.string_val = vtpm }
- };
-
- abstract_type result_type = abstract_type_int;
-
- XEN_CALL_("VTPM.get_instance");
- return session->ok;
-}
-
-
-bool
xen_vtpm_get_uuid(xen_session *session, char **result, xen_vtpm vtpm)
{
*result = session->ok ? xen_strdup_((char *)vtpm) : NULL;
diff --git a/tools/libxen/test/test_bindings.c b/tools/libxen/test/test_bindings.c
index 1e10ef4223..88fce8b35b 100644
--- a/tools/libxen/test/test_bindings.c
+++ b/tools/libxen/test/test_bindings.c
@@ -277,13 +277,7 @@ int main(int argc, char **argv)
*/
static xen_vm create_new_vm(xen_session *session)
{
- xen_cpu_feature_set *empty_cpu_feature_set =
- xen_cpu_feature_set_alloc(0);
-
- xen_cpu_feature_set *force_off_cpu_feature_set =
- xen_cpu_feature_set_alloc(1);
- force_off_cpu_feature_set->contents[0] = XEN_CPU_FEATURE_MMX;
-
+ xen_string_string_map *vcpus_params = xen_string_string_map_alloc(1);
xen_vm_record vm_record =
{
.name_label = "NewVM",
@@ -295,15 +289,10 @@ static xen_vm create_new_vm(xen_session *session)
.memory_dynamic_min = 128,
.memory_static_min = 128,
.vcpus_policy = "credit",
- .vcpus_params = "",
+ .vcpus_params = vcpus_params,
.vcpus_number = 2,
- .vcpus_features_required = empty_cpu_feature_set,
- .vcpus_features_can_use = empty_cpu_feature_set,
- .vcpus_features_force_on = empty_cpu_feature_set,
- .vcpus_features_force_off = force_off_cpu_feature_set,
.actions_after_shutdown = XEN_ON_NORMAL_EXIT_DESTROY,
.actions_after_reboot = XEN_ON_NORMAL_EXIT_RESTART,
- .actions_after_suspend = XEN_ON_NORMAL_EXIT_DESTROY,
.actions_after_crash = XEN_ON_CRASH_BEHAVIOUR_PRESERVE,
.hvm_boot = "",
.pv_bootloader = "pygrub",
@@ -317,9 +306,6 @@ static xen_vm create_new_vm(xen_session *session)
xen_vm vm;
xen_vm_create(session, &vm, &vm_record);
- xen_cpu_feature_set_free(empty_cpu_feature_set);
- xen_cpu_feature_set_free(force_off_cpu_feature_set);
-
if (!session->ok)
{
fprintf(stderr, "VM creation failed.\n");
@@ -382,8 +368,7 @@ static xen_vm create_new_vm(xen_session *session)
.vm = &vm_record_opt,
.vdi = &vdi0_record_opt,
.device = "xvda1",
- .mode = XEN_VBD_MODE_RW,
- .driver = XEN_DRIVER_TYPE_PARAVIRTUALISED
+ .mode = XEN_VBD_MODE_RW
};
xen_vbd vbd0;
diff --git a/tools/pygrub/src/fsimage/fsimage.c b/tools/pygrub/src/fsimage/fsimage.c
index ad0182d691..52a8a4b1ac 100644
--- a/tools/pygrub/src/fsimage/fsimage.c
+++ b/tools/pygrub/src/fsimage/fsimage.c
@@ -125,7 +125,7 @@ fsimage_file_dealloc(fsimage_file_t *file)
if (file->file != NULL)
fsi_close_file(file->file);
Py_XDECREF(file->fs);
- PyMem_DEL(file);
+ PyObject_DEL(file);
}
static char fsimage_file_type__doc__[] = "Filesystem image file";
@@ -226,7 +226,7 @@ fsimage_fs_dealloc (fsimage_fs_t *fs)
{
if (fs->fs != NULL)
fsi_close_fsimage(fs->fs);
- PyMem_DEL(fs);
+ PyObject_DEL(fs);
}
PyDoc_STRVAR(fsimage_fs_type__doc__, "Filesystem image");
diff --git a/tools/python/scripts/test_hvm_create.py b/tools/python/scripts/test_hvm_create.py
index 5d2aca5944..8effd42db9 100644
--- a/tools/python/scripts/test_hvm_create.py
+++ b/tools/python/scripts/test_hvm_create.py
@@ -72,6 +72,12 @@ vif_cfg = {
'MTU': 1500,
}
+console_cfg = {
+ 'protocol': 'rfb',
+ 'other_config': {'vncunused': 1, 'vncpasswd': 'testing'},
+}
+
+
import sys
import time
sys.path.append('/usr/lib/python')
@@ -125,6 +131,12 @@ def test_vm_create():
vif_cfg['VM'] = vm_uuid
vif_uuid = execute(server, 'VIF.create', (session, vif_cfg))
+ # Create a console
+ console_cfg['VM'] = vm_uuid
+ console_uuid = execute(server, 'console.create',
+ (session, console_cfg))
+ print console_uuid
+
# Start the VM
execute(server, 'VM.start', (session, vm_uuid, False))
diff --git a/tools/python/scripts/test_vm_create.py b/tools/python/scripts/test_vm_create.py
index 19a5135153..0d702aae69 100644
--- a/tools/python/scripts/test_vm_create.py
+++ b/tools/python/scripts/test_vm_create.py
@@ -91,6 +91,11 @@ vif_cfg = {
'network': '',
'MAC': '',
'MTU': 1500,
+}
+
+console_cfg = {
+ 'protocol': 'rfb',
+ 'other_config': {'vncunused': 1, 'vncpasswd': 'testing'},
}
import sys
@@ -157,12 +162,18 @@ def test_vm_create():
vif_cfg['VM'] = vm_uuid
vif_uuid = execute(server, 'VIF.create', (session, vif_cfg))
+ # Create a console
+ console_cfg['VM'] = vm_uuid
+ console_uuid = execute(server, 'console.create',
+ (session, console_cfg))
+ print console_uuid
+
# Start the VM
execute(server, 'VM.start', (session, vm_uuid, False))
time.sleep(30)
- test_suspend = True
+ test_suspend = False
if test_suspend:
print 'Suspending VM..'
execute(server, 'VM.suspend', (session, vm_uuid))
diff --git a/tools/python/scripts/xapi.py b/tools/python/scripts/xapi.py
index f1829e0a10..b5fe8b3682 100644
--- a/tools/python/scripts/xapi.py
+++ b/tools/python/scripts/xapi.py
@@ -45,7 +45,7 @@ VDI_LIST_FORMAT = '%(name_label)-18s %(uuid)-36s %(virtual_size)-8s '\
VBD_LIST_FORMAT = '%(device)-6s %(uuid)-36s %(VDI)-8s'
TASK_LIST_FORMAT = '%(name_label)-18s %(uuid)-36s %(status)-8s %(progress)-4s'
VIF_LIST_FORMAT = '%(name)-8s %(device)-7s %(uuid)-36s %(MAC)-10s'
-CONSOLE_LIST_FORMAT = '%(uuid)-36s %(protocol)-8s %(uri)-32s'
+CONSOLE_LIST_FORMAT = '%(uuid)-36s %(protocol)-8s %(location)-32s'
COMMANDS = {
'host-info': ('', 'Get Xen Host Info'),
@@ -545,7 +545,7 @@ def xapi_console_list(args, async = False):
if not is_long:
print CONSOLE_LIST_FORMAT % {'protocol': 'Protocol',
- 'uri': 'URI',
+ 'location': 'Location',
'uuid': 'UUID'}
for console in consoles:
@@ -678,14 +678,6 @@ def xapi_vtpm_create(args, async = False):
print "Creating vTPM with cfg = %s" % cfg
vtpm_uuid = execute(server, 'VTPM.create', (session, cfg))
print "Done. (%s)" % vtpm_uuid
- vtpm_id = execute(server, 'VTPM.get_instance', (session, vtpm_uuid))
- print "Has instance number '%s'" % vtpm_id
- vtpm_be = execute(server, 'VTPM.get_backend', (session, vtpm_uuid))
- print "Has backend in '%s'" % vtpm_be
- driver = execute(server, 'VTPM.get_driver', (session, vtpm_uuid))
- print "Has driver type '%s'" % driver
- vtpm_rec = execute(server, 'VTPM.get_record', (session, vtpm_uuid))
- print "Has vtpm record '%s'" % vtpm_rec
def xapi_pif_list(args, async = False):
diff --git a/tools/python/xen/xend/XendAPI.py b/tools/python/xen/xend/XendAPI.py
index b9e6dfe1c8..0b249f9449 100644
--- a/tools/python/xen/xend/XendAPI.py
+++ b/tools/python/xen/xend/XendAPI.py
@@ -12,7 +12,7 @@
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#============================================================================
-# Copyright (C) 2006 XenSource Ltd.
+# Copyright (C) 2006-2007 XenSource Ltd.
#============================================================================
import inspect
@@ -158,6 +158,17 @@ def valid_host(func):
_check_ref(XendNode.instance().is_valid_host,
'HOST_HANDLE_INVALID', func, *args, **kwargs)
+def valid_host_metrics(func):
+ """Decorator to verify if host_metrics_ref is valid before calling
+ method.
+
+ @param func: function with params: (self, session, host_metrics_ref)
+ @rtype: callable object
+ """
+ return lambda *args, **kwargs: \
+ _check_ref(lambda r: r == XendNode.instance().host_metrics_uuid,
+ 'HOST_METRICS_HANDLE_INVALID', func, *args, **kwargs)
+
def valid_host_cpu(func):
"""Decorator to verify if host_cpu_ref is valid before calling method.
@@ -261,6 +272,17 @@ def valid_pif(func):
_check_ref(lambda r: r in XendNode.instance().pifs,
'PIF_HANDLE_INVALID', func, *args, **kwargs)
+def valid_pif_metrics(func):
+ """Decorator to verify if pif_metrics_ref is valid before calling
+ method.
+
+ @param func: function with params: (self, session, pif_metrics_ref)
+ @rtype: callable object
+ """
+ return lambda *args, **kwargs: \
+ _check_ref(lambda r: r in XendNode.instance().pif_metrics,
+ 'PIF_METRICS_HANDLE_INVALID', func, *args, **kwargs)
+
def valid_task(func):
"""Decorator to verify if task_ref is valid before calling
method.
@@ -349,20 +371,22 @@ class XendAPI(object):
"""
global_validators = [session_required, catch_typeerror]
classes = {
- 'session' : None,
- 'host' : valid_host,
- 'host_cpu': valid_host_cpu,
- 'network' : valid_network,
- 'VM' : valid_vm,
- 'VBD' : valid_vbd,
- 'VIF' : valid_vif,
- 'VDI' : valid_vdi,
- 'VTPM' : valid_vtpm,
- 'console' : valid_console,
- 'SR' : valid_sr,
- 'PIF' : valid_pif,
- 'task' : valid_task,
- 'debug' : valid_debug,
+ 'session' : None,
+ 'host' : valid_host,
+ 'host_cpu' : valid_host_cpu,
+ 'host_metrics' : valid_host_metrics,
+ 'network' : valid_network,
+ 'VM' : valid_vm,
+ 'VBD' : valid_vbd,
+ 'VIF' : valid_vif,
+ 'VDI' : valid_vdi,
+ 'VTPM' : valid_vtpm,
+ 'console' : valid_console,
+ 'SR' : valid_sr,
+ 'PIF' : valid_pif,
+ 'PIF_metrics' : valid_pif_metrics,
+ 'task' : valid_task,
+ 'debug' : valid_debug,
}
# Cheat methods
@@ -372,6 +396,9 @@ class XendAPI(object):
# all get_by_uuid() methods.
for api_cls in classes.keys():
+ if api_cls == 'session':
+ continue
+
get_by_uuid = '%s_get_by_uuid' % api_cls
get_uuid = '%s_get_uuid' % api_cls
def _get_by_uuid(_1, _2, ref):
@@ -451,7 +478,6 @@ class XendAPI(object):
session_attr_ro = ['this_host', 'this_user']
session_methods = [('logout', None)]
- # session_funcs = ['login_with_password']
def session_login_with_password(self, *args):
if len(args) != 2:
@@ -473,15 +499,18 @@ class XendAPI(object):
def session_logout(self, session):
auth_manager().logout(session)
return xen_api_success_void()
- def session_destroy(self, session):
- return xen_api_error(XEND_ERROR_UNSUPPORTED)
def session_get_record(self, session):
- record = {'this_host': XendNode.instance().uuid,
+ record = {'uuid' : session,
+ 'this_host': XendNode.instance().uuid,
'this_user': auth_manager().get_user(session)}
return xen_api_success(record)
- def session_get_all(self):
- return xen_api_error(XEND_ERROR_UNSUPPORTED)
-
+
+ def session_get_uuid(self, session):
+ return xen_api_success(session)
+
+ def session_get_by_uuid(self, session):
+ return xen_api_success(session)
+
# attributes (ro)
def session_get_this_host(self, session):
return xen_api_success(XendNode.instance().uuid)
@@ -499,18 +528,30 @@ class XendAPI(object):
# Xen API: Class Tasks
# ----------------------------------------------------------------
- task_attr_ro = ['status',
+ task_attr_ro = ['name_label',
+ 'name_description',
+ 'status',
'progress',
- 'eta',
'type',
'result',
'error_code',
- 'error_info']
+ 'error_info',
+ 'allowed_operations',
+ 'session'
+ ]
- task_attr_rw = ['name_label',
- 'name_description']
+ task_attr_rw = []
+
+ task_funcs = [('get_by_name_label', 'Set(task)'),
+ ('cancel', None)]
+
+ def task_get_name_label(self, session, task_ref):
+ task = XendTaskManager.get_task(task_ref)
+ return xen_api_success(task.name_label)
- task_funcs = [('get_by_name_label', 'Set(task)')]
+ def task_get_name_description(self, session, task_ref):
+ task = XendTaskManager.get_task(task_ref)
+ return xen_api_success(task.name_description)
def task_get_status(self, session, task_ref):
task = XendTaskManager.get_task(task_ref)
@@ -520,10 +561,6 @@ class XendAPI(object):
task = XendTaskManager.get_task(task_ref)
return xen_api_success(task.progress)
- def task_get_eta(self, session, task_ref):
- task = XendTaskManager.get_task(task_ref)
- return xen_api_success(task.eta)
-
def task_get_type(self, session, task_ref):
task = XendTaskManager.get_task(task_ref)
return xen_api_success(task.type)
@@ -540,53 +577,45 @@ class XendAPI(object):
task = XendTaskManager.get_task(task_ref)
return xen_api_success(task.error_info)
- def task_get_name_label(self, session, task_ref):
- task = XendTaskManager.get_task(task_ref)
- return xen_api_success(task.name_label)
+ def task_get_allowed_operations(self, session, task_ref):
+ return xen_api_success({})
- def task_get_name_description(self, session, task_ref):
+ def task_get_session(self, session, task_ref):
task = XendTaskManager.get_task(task_ref)
- return xen_api_success(task.name_description)
-
- def task_set_name_label(self, session, task_ref, label):
- task = XendTaskManager.get_task(task_ref)
- task.name_label = label
- return xen_api_success_void()
-
- def task_set_name_description(self, session, task_ref, desc):
- task = XendTaskManager.get_task(task_ref)
- task.name_description = desc
- return xen_api_success_void()
+ return xen_api_success(task.session)
def task_get_all(self, session):
tasks = XendTaskManager.get_all_tasks()
return xen_api_success(tasks)
- def task_destroy(self, session, task_uuid):
- XendTaskManager.destroy_task(task_uuid)
- return xen_api_success_void()
-
def task_get_record(self, session, task_ref):
task = XendTaskManager.get_task(task_ref)
return xen_api_success(task.get_record())
+ def task_cancel(self, session, task_ref):
+ return xen_api_error('OPERATION_NOT_ALLOWED')
+
def task_get_by_name_label(self, session, name):
return xen_api_success(XendTaskManager.get_task_by_name(name))
- # Xen API: Class Host
+ # Xen API: Class host
# ----------------------------------------------------------------
host_attr_ro = ['software_version',
'resident_VMs',
- 'host_CPUs']
+ 'host_CPUs',
+ 'metrics']
host_attr_rw = ['name_label',
- 'name_description']
+ 'name_description',
+ 'other_config']
host_methods = [('disable', None),
('enable', None),
('reboot', None),
- ('shutdown', None)]
+ ('shutdown', None),
+ ('add_to_other_config', None),
+ ('remove_from_other_config', None)]
host_funcs = [('get_by_name_label', 'Set(host)')]
@@ -601,12 +630,31 @@ class XendAPI(object):
def host_set_name_description(self, session, host_ref, new_desc):
XendNode.instance().set_description(new_desc)
return xen_api_success_void()
+ def host_get_other_config(self, session, host_ref):
+ return xen_api_success(XendNode.instance().other_config)
+ def host_set_other_config(self, session, host_ref, other_config):
+ node = XendNode.instance()
+ node.other_config = dict(other_config)
+ node.save()
+ return xen_api_success_void()
+ def host_add_to_other_config(self, session, host_ref, key, value):
+ node = XendNode.instance()
+ node.other_config[key] = value
+ node.save()
+ return xen_api_success_void()
+ def host_remove_from_other_config(self, session, host_ref, key):
+ node = XendNode.instance()
+ del node.other_config[key]
+ node.save()
+ return xen_api_success_void()
def host_get_software_version(self, session, host_ref):
return xen_api_success(XendNode.instance().xen_version())
def host_get_resident_VMs(self, session, host_ref):
return xen_api_success(XendDomain.instance().get_domain_refs())
def host_get_host_CPUs(self, session, host_ref):
return xen_api_success(XendNode.instance().get_host_cpu_refs())
+ def host_get_metrics(self, _, ref):
+ return xen_api_success(XendNode.instance().host_metrics_uuid)
# object methods
def host_destroy(self, session, host_ref):
@@ -625,6 +673,7 @@ class XendAPI(object):
if not XendDomain.instance().allow_new_domains():
return xen_api_error(XEND_ERROR_HOST_RUNNING)
return xen_api_error(XEND_ERROR_UNSUPPORTED)
+
def host_get_record(self, session, host_ref):
node = XendNode.instance()
dom = XendDomain.instance()
@@ -633,7 +682,8 @@ class XendAPI(object):
'name_description': '',
'software_version': node.xen_version(),
'resident_VMs': dom.get_domain_refs(),
- 'host_CPUs': node.get_host_cpu_refs()}
+ 'host_CPUs': node.get_host_cpu_refs(),
+ 'metrics': node.host_metrics_uuid}
return xen_api_success(record)
# class methods
@@ -647,20 +697,16 @@ class XendAPI(object):
return xen_api_success([])
- # Xen API: Class Host_CPU
+ # Xen API: Class host_CPU
# ----------------------------------------------------------------
host_cpu_attr_ro = ['host',
'number',
- 'features',
'utilisation']
# attributes
def host_cpu_get_host(self, session, host_cpu_ref):
return xen_api_success(XendNode.instance().uuid)
- def host_cpu_get_features(self, session, host_cpu_ref):
- features = XendNode.instance().get_host_cpu_features(host_cpu_ref)
- return xen_api_success(features)
def host_cpu_get_utilisation(self, session, host_cpu_ref):
util = XendNode.instance().get_host_cpu_load(host_cpu_ref)
return xen_api_success(util)
@@ -676,7 +722,6 @@ class XendAPI(object):
record = {'uuid': host_cpu_ref,
'host': node.uuid,
'number': node.get_host_cpu_number(host_cpu_ref),
- 'features': node.get_host_cpu_features(host_cpu_ref),
'utilisation': node.get_host_cpu_load(host_cpu_ref)}
return xen_api_success(record)
@@ -685,6 +730,44 @@ class XendAPI(object):
return xen_api_success(XendNode.instance().get_host_cpu_refs())
+ # Xen API: Class host_metrics
+ # ----------------------------------------------------------------
+
+ host_metrics_attr_ro = ['memory_total',
+ 'memory_free',
+ 'host']
+ host_metrics_attr_rw = []
+ host_methods = []
+
+ def _host_metrics_get(self, ref, f):
+ return xen_api_success(getattr(node, f)())
+
+ def host_metrics_get_record(self, _, ref):
+ return xen_api_success({
+ 'uuid' : ref,
+ 'host' : XendNode.instance().uuid,
+ 'memory_total' : self._host_metrics_get_memory_total(),
+ 'memory_free' : self._host_metrics_get_memory_free(),
+ })
+
+ def host_metrics_get_host(self, _, ref):
+ return xen_api_success(XendNode.instance().uuid)
+
+ def host_metrics_get_memory_total(self, _, ref):
+ return xen_api_success(self._host_metrics_get_memory_total())
+
+ def host_metrics_get_memory_free(self, _, ref):
+ return xen_api_success(self._host_metrics_get_memory_free())
+
+ def _host_metrics_get_memory_total(self):
+ node = XendNode.instance()
+ return node.xc.physinfo()['total_memory'] * 1024
+
+ def _host_metrics_get_memory_free(self):
+ node = XendNode.instance()
+ return node.xc.physinfo()['free_memory'] * 1024
+
+
# Xen API: Class network
# ----------------------------------------------------------------
@@ -750,9 +833,8 @@ class XendAPI(object):
# Xen API: Class PIF
# ----------------------------------------------------------------
- PIF_attr_ro = ['io_read_kbs',
- 'io_write_kbs']
- PIF_attr_rw = ['name',
+ PIF_attr_ro = ['metrics']
+ PIF_attr_rw = ['device',
'network',
'host',
'MAC',
@@ -766,24 +848,11 @@ class XendAPI(object):
def _get_PIF(self, ref):
return XendNode.instance().pifs[ref]
- def PIF_create(self, _, name, network_uuid, host_uuid, mac, mtu, vlan):
- try:
- node = XendNode.instance()
- if host_uuid != node.uuid:
- return xen_api_error(['HOST_HANDLE_INVALID', host_uuid])
-
- elif _is_valid_ref(network_uuid, node.is_valid_network):
- network = node.get_network(network_uuid)
- return xen_api_success(node.PIF_create(name, mtu, vlan, mac,
- network))
- else:
- return xen_api_error(['NETWORK_HANDLE_INVALID', network_uuid])
- except NetworkAlreadyConnected, exn:
- return xen_api_error(['NETWORK_ALREADY_CONNECTED',
- network_uuid, exn.pif_uuid])
-
def PIF_destroy(self, _, ref):
- return xen_api_success(XendNode.instance().PIF_destroy(ref))
+ try:
+ return xen_api_success(XendNode.instance().PIF_destroy(ref))
+ except PIFIsPhysical, exn:
+ return xen_api_error(['PIF_IS_PHYSICAL', ref])
# object methods
def PIF_get_record(self, _, ref):
@@ -792,8 +861,11 @@ class XendAPI(object):
def PIF_get_all(self, _):
return xen_api_success(XendNode.instance().pifs.keys())
- def PIF_get_name(self, _, ref):
- return xen_api_success(self._get_PIF(ref).name)
+ def PIF_get_metrics(self, _, ref):
+ return xen_api_success(self._get_PIF(ref).metrics.uuid)
+
+ def PIF_get_device(self, _, ref):
+ return xen_api_success(self._get_PIF(ref).device)
def PIF_get_network(self, _, ref):
return xen_api_success(self._get_PIF(ref).network.uuid)
@@ -810,14 +882,8 @@ class XendAPI(object):
def PIF_get_VLAN(self, _, ref):
return xen_api_success(self._get_PIF(ref).vlan)
- def PIF_get_io_read_kbs(self, _, ref):
- return xen_api_success(self._get_PIF(ref).get_io_read_kbs())
-
- def PIF_get_io_write_kbs(self, _, ref):
- return xen_api_success(self._get_PIF(ref).get_io_write_kbs())
-
- def PIF_set_name(self, _, ref, name):
- return xen_api_success(self._get_PIF(ref).set_name(name))
+ def PIF_set_device(self, _, ref, device):
+ return xen_api_success(self._get_PIF(ref).set_device(device))
def PIF_set_MAC(self, _, ref, mac):
return xen_api_success(self._get_PIF(ref).set_mac(mac))
@@ -827,14 +893,48 @@ class XendAPI(object):
def PIF_create_VLAN(self, _, ref, network, vlan):
try:
- if _is_valid_ref(network, XendNode.instance().is_valid_network):
- return xen_api_success(XendNode.instance().PIF_create_VLAN(
- ref, network, vlan))
+ vlan = int(vlan)
+ except:
+ return xen_api_error(['VLAN_TAG_INVALID', vlan])
+
+ try:
+ node = XendNode.instance()
+
+ if _is_valid_ref(network, node.is_valid_network):
+ return xen_api_success(
+ node.PIF_create_VLAN(ref, network, vlan))
else:
return xen_api_error(['NETWORK_HANDLE_INVALID', network])
except NetworkAlreadyConnected, exn:
return xen_api_error(['NETWORK_ALREADY_CONNECTED',
network, exn.pif_uuid])
+ except VLANTagInvalid:
+ return xen_api_error(['VLAN_TAG_INVALID', vlan])
+
+
+ # Xen API: Class PIF_metrics
+ # ----------------------------------------------------------------
+
+ PIF_metrics_attr_ro = ['PIF',
+ 'io_read_kbs',
+ 'io_write_kbs']
+ PIF_metrics_attr_rw = []
+ PIF_methods = []
+
+ def _PIF_metrics_get(self, ref):
+ return XendNode.instance().pif_metrics[ref]
+
+ def PIF_metrics_get_record(self, _, ref):
+ return xen_api_success(self._PIF_metrics_get(ref).get_record())
+
+ def PIF_metrics_get_PIF(self, _, ref):
+ return xen_api_success(self._PIF_metrics_get(ref).pif.uuid)
+
+ def PIF_metrics_get_io_read_kbs(self, _, ref):
+ return xen_api_success(self._PIF_metrics_get(ref).get_io_read_kbs())
+
+ def PIF_metrics_get_io_write_kbs(self, _, ref):
+ return xen_api_success(self._PIF_metrics_get(ref).get_io_write_kbs())
# Xen API: Class VM
@@ -847,14 +947,13 @@ class XendAPI(object):
'memory_static_min',
'VCPUs_number',
'VCPUs_utilisation',
- 'VCPUs_features_required',
- 'VCPUs_can_use',
'consoles',
'VIFs',
'VBDs',
'VTPMs',
'PCI_bus',
'tools_version',
+ 'is_control_domain',
]
VM_attr_rw = ['name_label',
@@ -866,8 +965,6 @@ class XendAPI(object):
'memory_dynamic_min',
'VCPUs_policy',
'VCPUs_params',
- 'VCPUs_features_force_on',
- 'VCPUs_features_force_off',
'actions_after_shutdown',
'actions_after_reboot',
'actions_after_suspend',
@@ -884,7 +981,7 @@ class XendAPI(object):
'platform_clock_offset',
'platform_enable_audio',
'platform_keymap',
- 'otherConfig']
+ 'other_config']
VM_methods = [('clone', 'VM'),
('start', None),
@@ -896,8 +993,8 @@ class XendAPI(object):
('hard_reboot', None),
('suspend', None),
('resume', None),
- ('add_to_otherConfig', None),
- ('remove_from_otherConfig', None)]
+ ('add_to_other_config', None),
+ ('remove_from_other_config', None)]
VM_funcs = [('create', 'VM'),
('get_by_name_label', 'Set(VM)')]
@@ -914,10 +1011,6 @@ class XendAPI(object):
'memory_static_min',
'VCPUs_policy',
'VCPUs_params',
- 'VCPUs_features_required',
- 'VCPUs_features_can_use',
- 'VCPUs_features_force_on',
- 'VCPUs_features_force_off',
'actions_after_shutdown',
'actions_after_reboot',
'actions_after_suspend',
@@ -936,7 +1029,7 @@ class XendAPI(object):
'platform_keymap',
'grub_cmdline',
'PCI_bus',
- 'otherConfig']
+ 'other_config']
def VM_get(self, name, session, vm_ref):
return xen_api_success(
@@ -977,14 +1070,6 @@ class XendAPI(object):
dom = XendDomain.instance().get_vm_by_uuid(vm_ref)
return xen_api_success(dom.get_vcpus_util())
- def VM_get_VCPUs_features_required(self, session, vm_ref):
- dom = XendDomain.instance().get_vm_by_uuid(vm_ref)
- return xen_api_todo() # unsupported by xc
-
- def VM_get_VCPUs_can_use(self, session, vm_ref):
- dom = XendDomain.instance().get_vm_by_uuid(vm_ref)
- return xen_api_todo() # unsupported by xc
-
def VM_get_VIFs(self, session, vm_ref):
dom = XendDomain.instance().get_vm_by_uuid(vm_ref)
return xen_api_success(dom.get_vifs())
@@ -1042,14 +1127,6 @@ class XendAPI(object):
dom = XendDomain.instance().get_vm_by_uuid(vm_ref)
return xen_api_todo() # need access to scheduler
- def VM_get_VCPUs_features_force_on(self, session, vm_ref):
- dom = XendDomain.instance().get_vm_by_uuid(vm_ref)
- return xen_api_todo()
-
- def VM_get_VCPUs_features_force_off(self, session, vm_ref):
- dom = XendDomain.instance().get_vm_by_uuid(vm_ref)
- return xen_api_todo()
-
def VM_get_actions_after_shutdown(self, session, vm_ref):
dom = XendDomain.instance().get_vm_by_uuid(vm_ref)
return xen_api_success(dom.get_on_shutdown())
@@ -1108,8 +1185,13 @@ class XendAPI(object):
dom = XendDomain.instance().get_vm_by_uuid(vm_ref)
return xen_api_success(dom.get_platform_keymap())
- def VM_get_otherConfig(self, session, vm_ref):
- return self.VM_get('otherConfig', session, vm_ref)
+ def VM_get_other_config(self, session, vm_ref):
+ return self.VM_get('otherconfig', session, vm_ref)
+
+ def VM_get_is_control_domain(self, session, vm_ref):
+ xd = XendDomain.instance()
+ return xen_api_success(
+ xd.get_vm_by_uuid(vm_ref) == xd.privilegedDomain())
def VM_set_name_label(self, session, vm_ref, label):
dom = XendDomain.instance().get_vm_by_uuid(vm_ref)
@@ -1144,14 +1226,6 @@ class XendAPI(object):
dom = XendDomain.instance().get_vm_by_uuid(vm_ref)
return xen_api_todo()
- def VM_set_VCPUs_features_force_on(self, session, vm_ref, features):
- dom = XendDomain.instance().get_vm_by_uuid(vm_ref)
- return xen_api_todo()
-
- def VM_set_VCPUs_features_force_off(self, session, vm_ref, features):
- dom = XendDomain.instance().get_vm_by_uuid(vm_ref)
- return xen_api_todo()
-
def VM_set_actions_after_shutdown(self, session, vm_ref, action):
if action not in XEN_API_ON_NORMAL_EXIST:
return xen_api_error(['VM_ON_NORMAL_EXIT_INVALID', vm_ref])
@@ -1208,16 +1282,16 @@ class XendAPI(object):
def VM_set_platform_enable_audio(self, session, vm_ref, value):
return self.VM_set('platform_enable_audio', session, vm_ref, value)
- def VM_set_otherConfig(self, session, vm_ref, value):
+ def VM_set_other_config(self, session, vm_ref, value):
return self.VM_set('otherconfig', session, vm_ref, value)
- def VM_add_to_otherConfig(self, session, vm_ref, key, value):
+ def VM_add_to_other_config(self, session, vm_ref, key, value):
dom = XendDomain.instance().get_vm_by_uuid(vm_ref)
if dom and 'otherconfig' in dom.info:
dom.info['otherconfig'][key] = value
return xen_api_success_void()
- def VM_remove_from_otherConfig(self, session, vm_ref, key):
+ def VM_remove_from_other_config(self, session, vm_ref, key):
dom = XendDomain.instance().get_vm_by_uuid(vm_ref)
if dom and 'otherconfig' in dom.info \
and key in dom.info['otherconfig']:
@@ -1267,10 +1341,6 @@ class XendAPI(object):
'VCPUs_params': xeninfo.get_vcpus_params(),
'VCPUs_number': xeninfo.getVCpuCount(),
'VCPUs_utilisation': xeninfo.get_vcpus_util(),
- 'VCPUs_features_required': [],
- 'VCPUs_features_can_use': [],
- 'VCPUs_features_force_on': [],
- 'VCPUs_features_force_off': [],
'actions_after_shutdown': xeninfo.get_on_shutdown(),
'actions_after_reboot': xeninfo.get_on_reboot(),
'actions_after_suspend': xeninfo.get_on_suspend(),
@@ -1293,7 +1363,8 @@ class XendAPI(object):
'platform_keymap': xeninfo.get_platform_keymap(),
'PCI_bus': xeninfo.get_pci_bus(),
'tools_version': xeninfo.get_tools_version(),
- 'otherConfig': xeninfo.info.get('otherconfig'),
+ 'other_config': xeninfo.info.get('otherconfig'),
+ 'is_control_domain': xeninfo == xendom.privilegedDomain(),
}
return xen_api_success(record)
@@ -1352,9 +1423,9 @@ class XendAPI(object):
VBD_attr_rw = ['VM',
'VDI',
'device',
+ 'bootable',
'mode',
- 'type',
- 'driver']
+ 'type']
VBD_attr_inst = VBD_attr_rw
@@ -1419,45 +1490,43 @@ class XendAPI(object):
return xen_api_success_void()
# attributes (rw)
+ def _VBD_get(self, vbd_ref, prop):
+ return xen_api_success(
+ XendDomain.instance().get_dev_property_by_uuid(
+ 'vbd', vbd_ref, prop))
+
def VBD_get_VM(self, session, vbd_ref):
- xendom = XendDomain.instance()
- return xen_api_success(xendom.get_dev_property_by_uuid('vbd',
- vbd_ref, 'VM'))
+ return self._VBD_get(vbd_ref, 'VM')
def VBD_get_VDI(self, session, vbd_ref):
- xendom = XendDomain.instance()
- return xen_api_success(xendom.get_dev_property_by_uuid('vbd',
- vbd_ref, 'VDI'))
-
+ return self._VBD_get(vbd_ref, 'VDI')
+
def VBD_get_device(self, session, vbd_ref):
- xendom = XendDomain.instance()
- return xen_api_success(xendom.get_dev_property_by_uuid('vbd', vbd_ref,
- 'device'))
+ return self._VBD_get(vbd_ref, 'device')
+
+ def VBD_get_bootable(self, session, vbd_ref):
+ return self._VBD_get(vbd_ref, 'bootable')
+
def VBD_get_mode(self, session, vbd_ref):
- xendom = XendDomain.instance()
- return xen_api_success(xendom.get_dev_property_by_uuid('vbd', vbd_ref,
- 'mode'))
- def VBD_get_driver(self, session, vbd_ref):
- xendom = XendDomain.instance()
- return xen_api_success(xendom.get_dev_property_by_uuid('vbd', vbd_ref,
- 'driver'))
+ return self._VBD_get(vbd_ref, 'mode')
def VBD_get_type(self, session, vbd_ref):
- xendom = XendDomain.instance()
- return xen_api_success(xendom.get_dev_property_by_uuid('vbd', vbd_ref,
- 'type'))
+ return self._VBD_get(vbd_ref, 'type')
def VBD_get_io_read_kbs(self, session, vbd_ref):
- xendom = XendDomain.instance()
- return xen_api_success(xendom.get_dev_property_by_uuid('vbd', vbd_ref,
- 'io_read_kbs'))
-
+ return self._VBD_get(vbd_ref, 'io_read_kbs')
def VBD_get_io_write_kbs(self, session, vbd_ref):
- xendom = XendDomain.instance()
- return xen_api_success(xendom.get_dev_property_by_uuid('vbd', vbd_ref,
- 'io_read_kbs'))
-
+ return self._VBD_get(vbd_ref, 'io_write_kbs')
+
+ def VBD_set_bootable(self, session, vbd_ref, bootable):
+ bootable = bool(bootable)
+ xd = XendDomain.instance()
+ vm = xd.get_vm_with_dev_uuid('vbd', vbd_ref)
+ vm.set_dev_property('vbd', vbd_ref, 'bootable', bootable)
+ xd.managed_config_save(vm)
+ return xen_api_success_void()
+
def VBD_get_all(self, session):
xendom = XendDomain.instance()
vbds = [d.get_vbds() for d in XendDomain.instance().list('all')]
@@ -1469,9 +1538,7 @@ class XendAPI(object):
VIF_attr_ro = ['io_read_kbs',
'io_write_kbs']
- VIF_attr_rw = ['name',
- 'type',
- 'device',
+ VIF_attr_rw = ['device',
'network',
'VM',
'MAC',
@@ -1532,10 +1599,6 @@ class XendAPI(object):
vm = xendom.get_vm_with_dev_uuid('vif', vif_ref)
return xen_api_success(vm.get_uuid())
- def VIF_get_name(self, session, vif_ref):
- xendom = XendDomain.instance()
- return xen_api_success(xendom.get_dev_property_by_uuid('vif', vif_ref,
- 'name'))
def VIF_get_MTU(self, session, vif_ref):
xendom = XendDomain.instance()
return xen_api_success(xendom.get_dev_property_by_uuid('vif', vif_ref,
@@ -1545,17 +1608,10 @@ class XendAPI(object):
return xen_api_success(xendom.get_dev_property_by_uuid('vif', vif_ref,
'MAC'))
- def VIF_get_type(self, session, vif_ref):
- xendom = XendDomain.instance()
- return xen_api_success(xendom.get_dev_property_by_uuid('vif', vif_ref,
- 'type'))
-
-
def VIF_get_device(self, session, vif_ref):
xendom = XendDomain.instance()
return xen_api_success(xendom.get_dev_property_by_uuid('vif', vif_ref,
'device'))
-
def VIF_get_io_read_kbs(self, session, vif_ref):
xendom = XendDomain.instance()
@@ -1579,9 +1635,7 @@ class XendAPI(object):
VDI_attr_ro = ['VBDs',
'physical_utilisation',
'sector_size',
- 'type',
- 'parent',
- 'children']
+ 'type']
VDI_attr_rw = ['name_label',
'name_description',
'SR',
@@ -1610,12 +1664,6 @@ class XendAPI(object):
def VDI_get_type(self, session, vdi_ref):
return xen_api_success(self._get_VDI(vdi_ref).type)
- def VDI_get_parent(self, session, vdi_ref):
- return xen_api_success(self._get_VDI(vdi_ref).parent)
-
- def VDI_get_children(self, session, vdi_ref):
- return xen_api_success(self._get_VDI(vdi_ref).children)
-
def VDI_get_name_label(self, session, vdi_ref):
return xen_api_success(self._get_VDI(vdi_ref).name_label)
@@ -1677,8 +1725,6 @@ class XendAPI(object):
'physical_utilisation': image.physical_utilisation,
'sector_size': image.sector_size,
'type': image.type,
- 'parent': image.parent,
- 'children': image.children,
'sharable': image.sharable,
'read_only': image.read_only,
})
@@ -1708,9 +1754,7 @@ class XendAPI(object):
VTPM_attr_rw = [ ]
VTPM_attr_ro = ['VM',
- 'backend',
- 'instance',
- 'driver']
+ 'backend']
VTPM_attr_inst = VTPM_attr_rw
@@ -1727,41 +1771,14 @@ class XendAPI(object):
return xen_api_error(['VTPM_HANDLE_INVALID', vtpm_ref])
valid_vtpm_keys = self.VTPM_attr_ro + self.VTPM_attr_rw + \
self.Base_attr_ro + self.Base_attr_rw
+ return_cfg = {}
for k in cfg.keys():
- if k not in valid_vtpm_keys:
- del cfg[k]
+ if k in valid_vtpm_keys:
+ return_cfg[k] = cfg[k]
- return xen_api_success(cfg)
+ return xen_api_success(return_cfg)
# Class Functions
- def VTPM_get_instance(self, session, vtpm_ref):
- xendom = XendDomain.instance()
- vm = xendom.get_vm_with_dev_uuid('vtpm', vtpm_ref)
- if not vm:
- return xen_api_error(['VTPM_HANDLE_INVALID', vtpm_ref])
- cfg = vm.get_dev_xenapi_config('vtpm', vtpm_ref)
- if not cfg:
- return xen_api_error(['VTPM_HANDLE_INVALID', vtpm_ref])
- if cfg.has_key('instance'):
- instance = cfg['instance']
- else:
- instance = -1
- return xen_api_success(instance)
-
- def VTPM_get_driver(self, session, vtpm_ref):
- xendom = XendDomain.instance()
- vm = xendom.get_vm_with_dev_uuid('vtpm', vtpm_ref)
- if not vm:
- return xen_api_error(['VTPM_HANDLE_INVALID', vtpm_ref])
- cfg = vm.get_dev_xenapi_config('vtpm', vtpm_ref)
- if not cfg:
- return xen_api_error(['VTPM_HANDLE_INVALID', vtpm_ref])
- if cfg.has_key('type'):
- driver = cfg['type']
- else:
- driver = "Unknown"
- return xen_api_success(driver)
-
def VTPM_get_backend(self, session, vtpm_ref):
xendom = XendDomain.instance()
vm = xendom.get_vm_with_dev_uuid('vtpm', vtpm_ref)
@@ -1770,11 +1787,9 @@ class XendAPI(object):
cfg = vm.get_dev_xenapi_config('vtpm', vtpm_ref)
if not cfg:
return xen_api_error(['VTPM_HANDLE_INVALID', vtpm_ref])
- if cfg.has_key('backend'):
- backend = cfg['backend']
- else:
- backend = "Domain-0"
- return xen_api_success(backend)
+ if not cfg.has_key('backend'):
+ return xen_api_error(['VTPM backend not set'])
+ return xen_api_success(cfg['backend'])
def VTPM_get_VM(self, session, vtpm_ref):
xendom = XendDomain.instance()
@@ -1783,12 +1798,18 @@ class XendAPI(object):
def VTPM_destroy(self, session, vtpm_ref):
xendom = XendDomain.instance()
- vm = xendom.get_vm_with_dev_uuid('vtpm', vtpm_ref)
- if not vm:
- return xen_api_error(['VTPM_HANDLE_INVALID', vtpm_ref])
-
- vm.destroy_vtpm(vtpm_ref)
- return xen_api_success_void()
+ dom = xendom.get_vm_with_dev_uuid('vtpm', vtpm_ref)
+ if dom:
+ if dom.state != XEN_API_VM_POWER_STATE_HALTED:
+ vm_ref = dom.get_dev_property('vtpm', vtpm_ref, 'VM')
+ return xen_api_error(['VM_BAD_POWER_STATE', vm_ref,
+ XendDomain.POWER_STATE_NAMES[XEN_API_VM_POWER_STATE_HALTED],
+ XendDomain.POWER_STATE_NAMES[dom.state]])
+ from xen.xend.server import tpmif
+ tpmif.destroy_vtpmstate(dom.getName())
+ return xen_api_success(True)
+ else:
+ return xen_api_error(['VM_HANDLE_INVALID', vtpm_struct['VM']])
# class methods
def VTPM_create(self, session, vtpm_struct):
@@ -1814,8 +1835,9 @@ class XendAPI(object):
# ----------------------------------------------------------------
- console_attr_ro = ['uri', 'protocol', 'VM']
- console_attr_rw = []
+ console_attr_ro = ['location', 'protocol', 'VM']
+ console_attr_rw = ['other_config']
+ console_funcs = [('create', 'console')]
def console_get_all(self, session):
xendom = XendDomain.instance()
@@ -1823,10 +1845,10 @@ class XendAPI(object):
cons = reduce(lambda x, y: x + y, cons)
return xen_api_success(cons)
- def console_get_uri(self, session, console_ref):
+ def console_get_location(self, session, console_ref):
return xen_api_success(xendom.get_dev_property_by_uuid('console',
console_ref,
- 'uri'))
+ 'location'))
def console_get_protocol(self, session, console_ref):
return xen_api_success(xendom.get_dev_property_by_uuid('console',
@@ -1858,6 +1880,22 @@ class XendAPI(object):
return xen_api_success(return_cfg)
+ def console_create(self, session, console_struct):
+ xendom = XendDomain.instance()
+ if not xendom.is_valid_vm(console_struct['VM']):
+ return xen_api_error(['VM_HANDLE_INVALID', console_struct['VM']])
+
+ dom = xendom.get_vm_by_uuid(console_struct['VM'])
+ try:
+ if 'protocol' not in console_struct:
+ return xen_api_error(['CONSOLE_PROTOCOL_INVALID',
+ 'No protocol specified'])
+
+ console_ref = dom.create_console(console_struct)
+ xendom.managed_config_save(dom)
+ return xen_api_success(console_ref)
+ except XendError, e:
+ return xen_api_error([XEND_ERROR_TODO, str(e)])
# Xen API: Class SR
# ----------------------------------------------------------------
@@ -2022,19 +2060,22 @@ class XendAPIAsyncProxy:
# Only deal with method names that start with "Async."
if not method.startswith(self.method_prefix):
- raise Exception('Method %s not supported' % method)
-
- # Require 'session' argument to be present.
- if len(args) < 1:
- raise Exception('Not enough arguments')
+ return xen_api_error(['MESSAGE_METHOD_UNKNOWN', method])
# Lookup synchronous version of the method
synchronous_method_name = method[len(self.method_prefix):]
if synchronous_method_name not in self.method_map:
- raise Exception('Method %s not supported' % method)
+ return xen_api_error(['MESSAGE_METHOD_UNKNOWN', method])
method = self.method_map[synchronous_method_name]
+ # Check that we've got enough arguments before issuing a task ID.
+ needed = argcounts[method.api]
+ if len(args) != needed:
+ return xen_api_error(['MESSAGE_PARAMETER_COUNT_MISMATCH',
+ self.method_prefix + method.api, needed,
+ len(args)])
+
# Validate the session before proceeding
session = args[0]
if not auth_manager().is_session_valid(session):
@@ -2045,7 +2086,8 @@ class XendAPIAsyncProxy:
task_uuid = XendTaskManager.create_task(method, args,
synchronous_method_name,
return_type,
- synchronous_method_name)
+ synchronous_method_name,
+ session)
return xen_api_success(task_uuid)
#
diff --git a/tools/python/xen/xend/XendAPIConstants.py b/tools/python/xen/xend/XendAPIConstants.py
index 47b6b08fee..9805cf02a7 100644
--- a/tools/python/xen/xend/XendAPIConstants.py
+++ b/tools/python/xen/xend/XendAPIConstants.py
@@ -35,20 +35,6 @@ XEN_API_VM_POWER_STATE_SUSPENDED = 3
XEN_API_VM_POWER_STATE_SHUTTINGDOWN = 4
XEN_API_VM_POWER_STATE_UNKNOWN = 5
-XEN_API_CPU_FEATURE = [
- 'FPU', 'VME', 'DE', 'PSE', 'TSC', 'MSR', 'PAE'
- 'MCE', 'CX8', 'APIC', 'SEP', 'MTRR', 'PGE', 'MCA',
- 'CMOV', 'PAT', 'PSE36', 'PN', 'CLFLSH', 'DTES',
- 'ACPI', 'MMX', 'FXCR', 'XMM', 'XMM2', 'SELFSNOOP',
- 'HT', 'ACC', 'IA64', 'SYSCALL', 'MP', 'NX', 'MMXEXT',
- 'LM', 'THREEDNOWEXT', 'THREEDNOW', 'RECOVERY', 'LONGRUN',
- 'LRTI', 'CXMMX', 'K6_MTRR', 'CYRIX_ARR', 'CENTAUR_MCR',
- 'K8', 'K7', 'P3', 'P4', 'CONSTANT_TSC', 'FXSAVE_LEAK',
- 'XMM3', 'MWAIT', 'DSCPL', 'EST', 'TM2', 'CID', 'CX16',
- 'XTPR', 'XSTORE', 'XSTORE_EN', 'XCRYPT', 'XCRYPT_EN',
- 'LAHF_LM', 'CMP_LEGACY'
-]
-
XEN_API_ON_NORMAL_EXIT = [
'destroy',
'restart',
diff --git a/tools/python/xen/xend/XendAuthSessions.py b/tools/python/xen/xend/XendAuthSessions.py
index 5c9a4e9a2f..769c66f3fa 100644
--- a/tools/python/xen/xend/XendAuthSessions.py
+++ b/tools/python/xen/xend/XendAuthSessions.py
@@ -21,11 +21,6 @@ from xen.xend import uuid
from xen.xend.XendError import *
from xen.xend.XendLogging import log
-try:
- import PAM
-except ImportError:
- log.warn("python-pam is required for XenAPI support.")
-
class XendAuthSessions:
"""Keeps track of Xen API Login Sessions using PAM.
@@ -80,7 +75,11 @@ class XendAuthSessions:
"""
pam_auth = None
try:
+ import PAM
pam_auth = PAM.pam()
+ except ImportError:
+ log.warn("python-pam is required for XenAPI support.")
+ return False
except NameError:
# if PAM doesn't exist, let's ignore it
return False
diff --git a/tools/python/xen/xend/XendConfig.py b/tools/python/xen/xend/XendConfig.py
index 62b462f577..f17a5a2295 100644
--- a/tools/python/xen/xend/XendConfig.py
+++ b/tools/python/xen/xend/XendConfig.py
@@ -126,6 +126,7 @@ XENAPI_HVM_CFG = {
'platform_serial' : 'serial',
'platform_localtime': 'localtime',
'platform_keymap' : 'keymap',
+ 'HVM_boot': 'boot',
}
# List of XendConfig configuration keys that have no direct equivalent
@@ -250,7 +251,8 @@ LEGACY_IMAGE_CFG = [
('sdl', int),
('vncdisplay', int),
('vncunused', int),
- ('vncpasswd', str),
+ ('vncpasswd', str),
+ ('vnclisten', str),
]
LEGACY_IMAGE_HVM_CFG = [
@@ -379,6 +381,7 @@ class XendConfig(dict):
'vif_refs': [],
'vbd_refs': [],
'vtpm_refs': [],
+ 'other_config': {},
}
defaults['name_label'] = 'Domain-' + defaults['uuid']
@@ -660,6 +663,25 @@ class XendConfig(dict):
self['vbd_refs'] = cfg.get('vbd_refs', [])
self['vtpm_refs'] = cfg.get('vtpm_refs', [])
+ # coalesce hvm vnc frame buffer with vfb config
+ if self['image']['type'] == 'hvm' and self['image'].get('vnc', 0):
+ # add vfb device if it isn't there already
+ has_rfb = False
+ for console_uuid in self['console_refs']:
+ if self['devices'][console_uuid][1].get('protocol') == 'rfb':
+ has_rfb = True
+ break
+
+ if not has_rfb:
+ dev_config = ['vfb']
+ # copy VNC related params from image config to vfb dev conf
+ for key in ['vncpasswd', 'vncunused', 'vncdisplay',
+ 'vnclisten']:
+ if key in self['image']:
+ dev_config.append([key, self['image'][key]])
+
+ self.device_add('vfb', cfg_sxp = dev_config)
+
def _sxp_to_xapi_unsupported(self, sxp_cfg):
"""Read in an SXP configuration object and populate
@@ -756,7 +778,7 @@ class XendConfig(dict):
# currently unsupported options
self['image']['hvm']['device_model'] = LEGACY_DM
- self['image']['vnc'] = 1
+ self['image']['vnc'] = 0
self['image']['hvm']['pae'] = 1
if self['platform_enable_audio']:
@@ -878,6 +900,14 @@ class XendConfig(dict):
controller = domain.getDeviceController(cls)
configs = controller.configurations()
for config in configs:
+ if sxp.name(config) in ('vbd', 'tap'):
+ # The bootable flag is never written to the
+ # store as part of the device config.
+ dev_uuid = sxp.child_value(config, 'uuid')
+ dev_type, dev_cfg = self['devices'][dev_uuid]
+ is_bootable = dev_cfg.get('bootable', False)
+ config.append(['bootable', int(is_bootable)])
+
sxpr.append(['device', config])
found = True
@@ -948,6 +978,7 @@ class XendConfig(dict):
pass
if dev_type == 'vbd':
+ dev_info['bootable'] = False
if dev_info.get('dev', '').startswith('ioemu:'):
dev_info['driver'] = 'ioemu'
else:
@@ -964,13 +995,43 @@ class XendConfig(dict):
if param not in target:
target[param] = []
if dev_uuid not in target[param]:
+ if dev_type == 'vbd' and not target[param]:
+ # Compat hack -- this is the first disk, so mark it
+ # bootable.
+ dev_info['bootable'] = True
target[param].append(dev_uuid)
- elif dev_type in ('tap',):
+ elif dev_type == 'tap':
if 'vbd_refs' not in target:
target['vbd_refs'] = []
if dev_uuid not in target['vbd_refs']:
+ if not target['vbd_refs']:
+ # Compat hack -- this is the first disk, so mark it
+ # bootable.
+ dev_info['bootable'] = True
target['vbd_refs'].append(dev_uuid)
- elif dev_type in ('console',):
+
+ elif dev_type == 'vfb':
+ # Populate other config with aux data that is associated
+ # with vfb
+
+ other_config = {}
+ for key in ['vncunused', 'vncdisplay', 'vnclisten',
+ 'vncpasswd', 'type', 'display', 'xauthority',
+ 'keymap']:
+ if key in dev_info:
+ other_config[key] = dev_info[key]
+ target['devices'][dev_uuid][1]['other_config'] = other_config
+
+
+ if 'console_refs' not in target:
+ target['console_refs'] = []
+
+ # Treat VFB devices as console devices so they are found
+ # through Xen API
+ if dev_uuid not in target['console_refs']:
+ target['console_refs'].append(dev_uuid)
+
+ elif dev_type == 'console':
if 'console_refs' not in target:
target['console_refs'] = []
if dev_uuid not in target['console_refs']:
@@ -1009,6 +1070,7 @@ class XendConfig(dict):
dev_info['uname'] = cfg_xenapi.get('image', '')
dev_info['dev'] = '%s:%s' % (cfg_xenapi.get('device'),
old_vbd_type)
+ dev_info['bootable'] = cfg_xenapi.get('bootable', False)
dev_info['driver'] = cfg_xenapi.get('driver')
dev_info['VDI'] = cfg_xenapi.get('VDI', '')
@@ -1031,50 +1093,117 @@ class XendConfig(dict):
target['devices'][dev_uuid] = (dev_type, dev_info)
target['vtpm_refs'].append(dev_uuid)
+ elif dev_type == 'console':
+ dev_uuid = cfg_xenapi.get('uuid', uuid.createString())
+ dev_info['uuid'] = dev_uuid
+ dev_info['protocol'] = cfg_xenapi.get('protocol', 'rfb')
+ dev_info['other_config'] = cfg_xenapi.get('other_config', {})
+ if dev_info['protocol'] == 'rfb':
+ # collapse other config into devinfo for things
+ # such as vncpasswd, vncunused, etc.
+ dev_info.update(cfg_xenapi.get('other_config', {}))
+ dev_info['type'] = 'vnc'
+ target['devices'][dev_uuid] = ('vfb', dev_info)
+ target['console_refs'].append(dev_uuid)
+
+ # Finally, if we are a pvfb, we need to make a vkbd
+ # as well that is not really exposed to Xen API
+ vkbd_uuid = uuid.createString()
+ target['devices'][vkbd_uuid] = ('vkbd', {})
+
+ elif dev_info['protocol'] == 'vt100':
+ # if someone tries to create a VT100 console
+ # via the Xen API, we'll have to ignore it
+ # because we create one automatically in
+ # XendDomainInfo._update_consoles
+ raise XendConfigError('Creating vt100 consoles via '
+ 'Xen API is unsupported')
+
return dev_uuid
# no valid device to add
return ''
- def console_add(self, protocol, uri):
+ def console_add(self, protocol, location, other_config = {}):
dev_uuid = uuid.createString()
- dev_info = {
- 'uuid': dev_uuid,
- 'protocol': protocol,
- 'uri': uri
- }
- if 'devices' not in self:
- self['devices'] = {}
+ if protocol == 'vt100':
+ dev_info = {
+ 'uuid': dev_uuid,
+ 'protocol': protocol,
+ 'location': location,
+ 'other_config': other_config,
+ }
+
+ if 'devices' not in self:
+ self['devices'] = {}
- self['devices'][dev_uuid] = ('console', dev_info)
- self['console_refs'].append(dev_uuid)
- return dev_info
+ self['devices'][dev_uuid] = ('console', dev_info)
+ self['console_refs'].append(dev_uuid)
+ return dev_info
+
+ return {}
+
+ def console_update(self, console_uuid, key, value):
+ for dev_uuid, (dev_type, dev_info) in self['devices'].items():
+ if dev_uuid == console_uuid:
+ dev_info[key] = value
+ break
def console_get_all(self, protocol):
- consoles = [dinfo for dtype, dinfo in self['devices'].values()
- if dtype == 'console']
- return [c for c in consoles if c.get('protocol') == protocol]
+ if protocol == 'vt100':
+ consoles = [dinfo for dtype, dinfo in self['devices'].values()
+ if dtype == 'console']
+ return [c for c in consoles if c.get('protocol') == protocol]
+
+ elif protocol == 'rfb':
+ vfbs = [dinfo for dtype, dinfo in self['devices'].values()
+ if dtype == 'vfb']
+
+ # move all non-console key values to other_config before
+ # returning console config
+ valid_keys = ['uuid', 'location']
+ for vfb in vfbs:
+ other_config = {}
+ for key, val in vfb.items():
+ if key not in valid_keys:
+ other_config[key] = vfb[key]
+ del vfb[key]
+ vfb['other_config'] = other_config
+ vfb['protocol'] = 'rfb'
+
+ return vfbs
+
+ else:
+ return []
- def device_update(self, dev_uuid, cfg_sxp):
+ def device_update(self, dev_uuid, cfg_sxp = [], cfg_xenapi = {}):
"""Update an existing device with the new configuration.
@rtype: boolean
@return: Returns True if succesfully found and updated a device conf
"""
- if dev_uuid in self['devices']:
+ if dev_uuid in self['devices'] and cfg_sxp:
if sxp.child0(cfg_sxp) == 'device':
config = sxp.child0(cfg_sxp)
else:
config = cfg_sxp
-
+
+ dev_type, dev_info = self['devices'][dev_uuid]
for opt_val in config[1:]:
try:
opt, val = opt_val
- self['devices'][dev_uuid][opt] = val
+ dev_info[opt] = val
except (TypeError, ValueError):
pass # no value for this config option
-
+
+ self['devices'][dev_uuid] = (dev_type, dev_info)
return True
+
+ elif dev_uuid in self['devices'] and cfg_xenapi:
+ dev_type, dev_info = self['devices'][dev_uuid]
+ for key, val in cfg_xenapi.items():
+ dev_info[key] = val
+ self['devices'][dev_uuid] = (dev_type, dev_info)
return False
diff --git a/tools/python/xen/xend/XendDomain.py b/tools/python/xen/xend/XendDomain.py
index d8a23197da..303a615ad8 100644
--- a/tools/python/xen/xend/XendDomain.py
+++ b/tools/python/xen/xend/XendDomain.py
@@ -32,7 +32,7 @@ import threading
import xen.lowlevel.xc
-from xen.xend import XendOptions, XendCheckpoint, XendDomainInfo
+from xen.xend import XendOptions, XendCheckpoint, XendDomainInfo, XendNode
from xen.xend.PrettyPrint import prettyprint
from xen.xend.XendConfig import XendConfig
from xen.xend.XendError import XendError, XendInvalidDomain, VmError
@@ -868,9 +868,10 @@ class XendDomain:
self._refresh()
dominfo = XendDomainInfo.create(config)
- self.domain_sched_credit_set(dominfo.getDomid(),
- dominfo.getWeight(),
- dominfo.getCap())
+ if XendNode.instance().xenschedinfo() == 'credit':
+ self.domain_sched_credit_set(dominfo.getDomid(),
+ dominfo.getWeight(),
+ dominfo.getCap())
return dominfo
finally:
self.domains_lock.release()
@@ -887,9 +888,10 @@ class XendDomain:
self._refresh()
dominfo = XendDomainInfo.create_from_dict(config_dict)
- self.domain_sched_credit_set(dominfo.getDomid(),
- dominfo.getWeight(),
- dominfo.getCap())
+ if XendNode.instance().xenschedinfo() == 'credit':
+ self.domain_sched_credit_set(dominfo.getDomid(),
+ dominfo.getWeight(),
+ dominfo.getCap())
return dominfo
finally:
self.domains_lock.release()
@@ -943,9 +945,10 @@ class XendDomain:
POWER_STATE_NAMES[dominfo.state])
dominfo.start(is_managed = True)
- self.domain_sched_credit_set(dominfo.getDomid(),
- dominfo.getWeight(),
- dominfo.getCap())
+ if XendNode.instance().xenschedinfo() == 'credit':
+ self.domain_sched_credit_set(dominfo.getDomid(),
+ dominfo.getWeight(),
+ dominfo.getCap())
finally:
self.domains_lock.release()
dominfo.waitForDevices()
diff --git a/tools/python/xen/xend/XendDomainInfo.py b/tools/python/xen/xend/XendDomainInfo.py
index a0c6c6ffa7..d657d4a1f1 100644
--- a/tools/python/xen/xend/XendDomainInfo.py
+++ b/tools/python/xen/xend/XendDomainInfo.py
@@ -695,16 +695,29 @@ class XendDomainInfo:
if not serial_consoles:
cfg = self.info.console_add('vt100', self.console_port)
self._createDevice('console', cfg)
+ else:
+ console_uuid = serial_consoles[0].get('uuid')
+ self.info.console_update(console_uuid, 'location',
+ self.console_port)
+
- # Update VNC port if it exists
+ # Update VNC port if it exists and write to xenstore
vnc_port = self.readDom('console/vnc-port')
if vnc_port is not None:
- vnc_consoles = self.info.console_get_all('rfb')
- if not vnc_consoles:
- cfg = self.info.console_add('rfb', 'localhost:%s' %
- str(vnc_port))
- self._createDevice('console', cfg)
+ for dev_uuid, (dev_type, dev_info) in self.info['devices'].items():
+ if dev_type == 'vfb':
+ old_location = dev_info.get('location')
+ listen_host = dev_info.get('vnclisten', 'localhost')
+ new_location = '%s:%s' % (listen_host, str(vnc_port))
+ if old_location == new_location:
+ break
+ dev_info['location'] = new_location
+ self.info.device_update(dev_uuid, cfg_xenapi = dev_info)
+ vfb_ctrl = self.getDeviceController('vfb')
+ vfb_ctrl.reconfigureDevice(0, dev_info)
+ break
+
#
# Function to update xenstore /vm/*
#
@@ -1653,48 +1666,47 @@ class XendDomainInfo:
blexec = osdep.pygrub_path
blcfg = None
- for (devtype, devinfo) in self.info.all_devices_sxpr():
- if not devtype or not devinfo or devtype not in ('vbd', 'tap'):
- continue
- disk = None
- for param in devinfo:
- if param[0] == 'uname':
- disk = param[1]
- break
+ disks = [x for x in self.info['vbd_refs']
+ if self.info['devices'][x][1]['bootable']]
- if disk is None:
- continue
- fn = blkdev_uname_to_file(disk)
- mounted = devtype == 'tap' and not os.stat(fn).st_rdev
- if mounted:
- # This is a file, not a device. pygrub can cope with a
- # file if it's raw, but if it's QCOW or other such formats
- # used through blktap, then we need to mount it first.
+ if not disks:
+ msg = "Had a bootloader specified, but no disks are bootable"
+ log.error(msg)
+ raise VmError(msg)
- log.info("Mounting %s on %s." %
- (fn, BOOTLOADER_LOOPBACK_DEVICE))
+ devinfo = self.info['devices'][disks[0]]
+ devtype = devinfo[0]
+ disk = devinfo[1]['uname']
- vbd = {
- 'mode': 'RO',
- 'device': BOOTLOADER_LOOPBACK_DEVICE,
- }
+ fn = blkdev_uname_to_file(disk)
+ mounted = devtype == 'tap' and not os.stat(fn).st_rdev
+ if mounted:
+ # This is a file, not a device. pygrub can cope with a
+ # file if it's raw, but if it's QCOW or other such formats
+ # used through blktap, then we need to mount it first.
- from xen.xend import XendDomain
- dom0 = XendDomain.instance().privilegedDomain()
- dom0._waitForDeviceUUID(dom0.create_vbd(vbd, fn))
- fn = BOOTLOADER_LOOPBACK_DEVICE
+ log.info("Mounting %s on %s." %
+ (fn, BOOTLOADER_LOOPBACK_DEVICE))
- try:
- blcfg = bootloader(blexec, fn, self, False,
- bootloader_args, kernel, ramdisk, args)
- finally:
- if mounted:
- log.info("Unmounting %s from %s." %
- (fn, BOOTLOADER_LOOPBACK_DEVICE))
+ vbd = {
+ 'mode': 'RO',
+ 'device': BOOTLOADER_LOOPBACK_DEVICE,
+ }
- dom0.destroyDevice('tap', '/dev/xvdp')
+ from xen.xend import XendDomain
+ dom0 = XendDomain.instance().privilegedDomain()
+ dom0._waitForDeviceUUID(dom0.create_vbd(vbd, fn))
+ fn = BOOTLOADER_LOOPBACK_DEVICE
- break
+ try:
+ blcfg = bootloader(blexec, fn, self, False,
+ bootloader_args, kernel, ramdisk, args)
+ finally:
+ if mounted:
+ log.info("Unmounting %s from %s." %
+ (fn, BOOTLOADER_LOOPBACK_DEVICE))
+
+ dom0.destroyDevice('tap', '/dev/xvdp')
if blcfg is None:
msg = "Had a bootloader specified, but can't find disk"
@@ -2018,21 +2030,18 @@ class XendDomainInfo:
@rtype: dictionary
"""
- dev_type_config = self.info['devices'].get(dev_uuid)
+ dev_type, dev_config = self.info['devices'].get(dev_uuid, (None, None))
# shortcut if the domain isn't started because
# the devcontrollers will have no better information
# than XendConfig.
if self.state in (XEN_API_VM_POWER_STATE_HALTED,):
- if dev_type_config:
- return copy.deepcopy(dev_type_config[1])
+ if dev_config:
+ return copy.deepcopy(dev_config)
return None
# instead of using dev_class, we use the dev_type
# that is from XendConfig.
- # This will accomdate 'tap' as well as 'vbd'
- dev_type = dev_type_config[0]
-
controller = self.getDeviceController(dev_type)
if not controller:
return None
@@ -2041,14 +2050,14 @@ class XendDomainInfo:
if not all_configs:
return None
- dev_config = copy.deepcopy(dev_type_config[1])
+ updated_dev_config = copy.deepcopy(dev_config)
for _devid, _devcfg in all_configs.items():
if _devcfg.get('uuid') == dev_uuid:
- dev_config.update(_devcfg)
- dev_config['id'] = _devid
- return dev_config
+ updated_dev_config.update(_devcfg)
+ updated_dev_config['id'] = _devid
+ return updated_dev_config
- return dev_config
+ return updated_dev_config
def get_dev_xenapi_config(self, dev_class, dev_uuid):
config = self.get_dev_config_by_uuid(dev_class, dev_uuid)
@@ -2126,7 +2135,10 @@ class XendDomainInfo:
config['mode'] = 'RW'
if dev_class == 'vtpm':
- config['driver'] = 'paravirtualised' # TODO
+ if not config.has_key('type'):
+ config['type'] = 'paravirtualised' # TODO
+ if not config.has_key('backend'):
+ config['backend'] = "00000000-0000-0000-0000-000000000000"
return config
@@ -2137,6 +2149,9 @@ class XendDomainInfo:
except KeyError:
raise XendError('Invalid property for device: %s' % field)
+ def set_dev_property(self, dev_class, dev_uuid, field, value):
+ self.info['devices'][dev_uuid][1][field] = value
+
def get_vcpus_util(self):
vcpu_util = {}
xennode = XendNode.instance()
@@ -2225,6 +2240,21 @@ class XendDomainInfo:
return dev_uuid
+ def create_console(self, xenapi_console):
+ """ Create a console device from a Xen API struct.
+
+ @return: uuid of device
+ @rtype: string
+ """
+ if self.state not in (DOM_STATE_HALTED,):
+ raise VmError("Can only add console to a halted domain.")
+
+ dev_uuid = self.info.device_add('console', cfg_xenapi = xenapi_console)
+ if not dev_uuid:
+ raise XendError('Failed to create device')
+
+ return dev_uuid
+
def destroy_device_by_uuid(self, dev_type, dev_uuid):
if dev_uuid not in self.info['devices']:
raise XendError('Device does not exist')
diff --git a/tools/python/xen/xend/XendError.py b/tools/python/xen/xend/XendError.py
index 439133d9a0..f1507c43dc 100644
--- a/tools/python/xen/xend/XendError.py
+++ b/tools/python/xen/xend/XendError.py
@@ -43,6 +43,14 @@ class NetworkAlreadyConnected(XendError):
XendError.__init__(self, 'Network already connected')
self.pif_uuid = pif_uuid
+class PIFIsPhysical(XendError):
+ def __init__(self):
+ XendError.__init__(self, 'PIF is physical')
+
+class VLANTagInvalid(XendError):
+ def __init__(self):
+ XendError.__init__(self, 'VLAN tag invalid')
+
class VmError(XendError):
"""Vm construction error."""
pass
diff --git a/tools/python/xen/xend/XendNode.py b/tools/python/xen/xend/XendNode.py
index 713dc081d4..294959752b 100644
--- a/tools/python/xen/xend/XendNode.py
+++ b/tools/python/xen/xend/XendNode.py
@@ -13,7 +13,7 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#============================================================================
# Copyright (C) 2004, 2005 Mike Wray <mike.wray@hp.com>
-# Copyright (c) 2006 Xensource Inc.
+# Copyright (c) 2006, 2007 Xensource Inc.
#============================================================================
import os
@@ -23,12 +23,13 @@ import xen.lowlevel.xc
from xen.util import Brctl
from xen.xend import uuid
-from xen.xend.XendError import XendError, NetworkAlreadyConnected
+from xen.xend.XendError import *
from xen.xend.XendOptions import instance as xendoptions
from xen.xend.XendQCoWStorageRepo import XendQCoWStorageRepo
from xen.xend.XendLocalStorageRepo import XendLocalStorageRepo
from xen.xend.XendLogging import log
from xen.xend.XendPIF import *
+from xen.xend.XendPIFMetrics import XendPIFMetrics
from xen.xend.XendNetwork import *
from xen.xend.XendStateStore import XendStateStore
from xen.xend.XendMonitor import XendMonitor
@@ -39,10 +40,12 @@ class XendNode:
def __init__(self):
"""Initalises the state of all host specific objects such as
- * Host
- * Host_CPU
+ * host
+ * host_CPU
+ * host_metrics
* PIF
- * Network
+ * PIF_metrics
+ * network
* Storage Repository
"""
@@ -58,12 +61,20 @@ class XendNode:
host = saved_host[self.uuid]
self.name = host.get('name_label', socket.gethostname())
self.desc = host.get('name_description', '')
+ self.host_metrics_uuid = host.get('metrics_uuid',
+ uuid.createString())
+ try:
+ self.other_config = eval(host['other_config'])
+ except:
+ self.other_config = {}
self.cpus = {}
else:
self.uuid = uuid.createString()
self.name = socket.gethostname()
self.desc = ''
+ self.other_config = {}
self.cpus = {}
+ self.host_metrics_uuid = uuid.createString()
# load CPU UUIDs
saved_cpus = self.state_store.load_state('cpu')
@@ -88,6 +99,7 @@ class XendNode:
self.cpus[cpu_uuid] = cpu_info
self.pifs = {}
+ self.pif_metrics = {}
self.networks = {}
self.srs = {}
@@ -111,8 +123,22 @@ class XendNode:
if pif.get('network') in self.networks:
network = self.networks[pif['network']]
try:
- self.PIF_create(pif['name'], pif['MTU'], pif['VLAN'],
- pif['MAC'], network, False, pif_uuid)
+ if 'device' not in pif and 'name' in pif:
+ # Compatibility hack, can go pretty soon.
+ pif['device'] = pif['name']
+ if 'metrics' not in pif:
+ # Compatibility hack, can go pretty soon.
+ pif['metrics'] = uuid.createString()
+
+ try:
+ pif['VLAN'] = int(pif.get('VLAN', -1))
+ except (ValueError, TypeError):
+ pif['VLAN'] = -1
+
+ self._PIF_create(pif['device'], pif['MTU'],
+ pif['VLAN'],
+ pif['MAC'], network, False, pif_uuid,
+ pif['metrics'])
except NetworkAlreadyConnected, exn:
log.error('Cannot load saved PIF %s, as network %s ' +
'is already connected to PIF %s',
@@ -120,7 +146,7 @@ class XendNode:
else:
for name, mtu, mac in linux_get_phy_ifaces():
network = self.networks.values()[0]
- self.PIF_create(name, mtu, '', mac, network, False)
+ self._PIF_create(name, mtu, -1, mac, network, False)
# initialise storage
saved_srs = self.state_store.load_state('sr')
@@ -161,16 +187,24 @@ class XendNode:
self.save_networks()
- def PIF_create(self, name, mtu, vlan, mac, network, persist = True,
- pif_uuid = None):
+ def _PIF_create(self, name, mtu, vlan, mac, network, persist = True,
+ pif_uuid = None, metrics_uuid = None):
for pif in self.pifs.values():
if pif.network == network:
raise NetworkAlreadyConnected(pif.uuid)
if pif_uuid is None:
pif_uuid = uuid.createString()
- self.pifs[pif_uuid] = XendPIF(pif_uuid, name, mtu, vlan, mac, network,
- self)
+ if metrics_uuid is None:
+ metrics_uuid = uuid.createString()
+
+ metrics = XendPIFMetrics(metrics_uuid)
+ pif = XendPIF(pif_uuid, metrics, name, mtu, vlan, mac, network, self)
+ metrics.set_PIF(pif)
+
+ self.pif_metrics[metrics_uuid] = metrics
+ self.pifs[pif_uuid] = pif
+
if persist:
self.save_PIFs()
self.refreshBridges()
@@ -178,12 +212,20 @@ class XendNode:
def PIF_create_VLAN(self, pif_uuid, network_uuid, vlan):
+ if vlan < 0 or vlan >= 4096:
+ raise VLANTagInvalid()
+
pif = self.pifs[pif_uuid]
network = self.networks[network_uuid]
- return self.PIF_create(pif.name, pif.mtu, vlan, pif.mac, network)
+ return self._PIF_create(pif.device, pif.mtu, vlan, pif.mac, network)
def PIF_destroy(self, pif_uuid):
+ pif = self.pifs[pif_uuid]
+
+ if pif.vlan == -1:
+ raise PIFIsPhysical()
+
del self.pifs[pif_uuid]
self.save_PIFs()
@@ -191,7 +233,9 @@ class XendNode:
def save(self):
# save state
host_record = {self.uuid: {'name_label':self.name,
- 'name_description':self.desc}}
+ 'name_description':self.desc,
+ 'metrics_uuid': self.host_metrics_uuid,
+ 'other_config': repr(self.other_config)}}
self.state_store.save_state('host',host_record)
self.state_store.save_state('cpu', self.cpus)
self.save_PIFs()
@@ -199,7 +243,7 @@ class XendNode:
self.save_SRs()
def save_PIFs(self):
- pif_records = dict([(k, v.get_record(transient = False))
+ pif_records = dict([(k, v.get_record())
for k, v in self.pifs.items()])
self.state_store.save_state('pif', pif_records)
@@ -482,12 +526,6 @@ class XendNode:
return vbd_loads[domid].get(vbdid, (0.0, 0.0))
return (0.0, 0.0)
- def get_pif_util(self, pifname):
- pifs_util = self.monitor.get_pifs_util()
- if pifname in pifs_util:
- return pifs_util[pifname]
- return (0.0, 0.0)
-
# dictionary version of *info() functions to get rid of
# SXPisms.
def nodeinfo_dict(self):
diff --git a/tools/python/xen/xend/XendPIF.py b/tools/python/xen/xend/XendPIF.py
index 057d1335ec..efb65989e9 100644
--- a/tools/python/xen/xend/XendPIF.py
+++ b/tools/python/xen/xend/XendPIF.py
@@ -90,18 +90,20 @@ def linux_set_mtu(iface, mtu):
class XendPIF:
"""Representation of a Physical Network Interface."""
- def __init__(self, uuid, name, mtu, vlan, mac, network, host):
+ def __init__(self, uuid, metrics, device, mtu, vlan, mac, network,
+ host):
self.uuid = uuid
- self.name = name
+ self.metrics = metrics
+ self.device = device
self.mac = mac
self.mtu = mtu
self.vlan = vlan
self.network = network
self.host = host
- def set_name(self, new_name):
- self.name = new_name
-
+ def set_device(self, new_device):
+ self.device = new_device
+
def set_mac(self, new_mac):
success = linux_set_mac(new_mac)
if success:
@@ -114,26 +116,15 @@ class XendPIF:
self.mtu = new_mtu
return success
- def get_io_read_kbs(self):
- from xen.xend.XendNode import instance as xennode
- return xennode().get_pif_util(self.name)[0]
-
- def get_io_write_kbs(self):
- from xen.xend.XendNode import instance as xennode
- return xennode().get_pif_util(self.name)[1]
-
- def get_record(self, transient = True):
- result = {'name': self.name,
- 'MAC': self.mac,
- 'MTU': self.mtu,
- 'VLAN': self.vlan,
- 'host': self.host.uuid,
- 'network': self.network.uuid}
- if transient:
- result['io_read_kbs'] = self.get_io_read_kbs()
- result['io_write_kbs'] = self.get_io_write_kbs()
- return result
-
+ def get_record(self):
+ return {'uuid': self.uuid,
+ 'device': self.device,
+ 'MAC': self.mac,
+ 'MTU': self.mtu,
+ 'VLAN': self.vlan,
+ 'host': self.host.uuid,
+ 'network': self.network.uuid,
+ 'metrics': self.metrics.uuid}
def refresh(self, bridges):
ifname = self.interface_name()
@@ -143,13 +134,14 @@ class XendPIF:
# there's nothing we can do -- this should have been set up with
# the network script. Otherwise, we can use vconfig to derive
# a subinterface.
- if not self.vlan:
+ if self.vlan == -1:
return
- rc, _ = _cmd('vconfig add %s %s', self.name, self.vlan)
+ rc, _ = _cmd('vconfig add %s %d', self.device, self.vlan)
if rc != 0:
- log.error('Could not refresh %s', ifname)
+ log.error('Could not refresh VLAN for interface %s', ifname)
return
+
log.info('Created network interface %s', ifname)
for brname, nics in bridges.items():
@@ -175,10 +167,10 @@ class XendPIF:
def interface_name(self):
- if self.vlan:
- return '%s.%s' % (self.name, self.vlan)
+ if self.vlan != -1:
+ return '%s.%d' % (self.device, self.vlan)
else:
- return self.name
+ return self.device
def _cmd(cmd, *args):
diff --git a/tools/python/xen/xend/XendPIFMetrics.py b/tools/python/xen/xend/XendPIFMetrics.py
new file mode 100644
index 0000000000..8c65251664
--- /dev/null
+++ b/tools/python/xen/xend/XendPIFMetrics.py
@@ -0,0 +1,47 @@
+#============================================================================
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of version 2.1 of the GNU Lesser General Public
+# License as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#============================================================================
+# Copyright (c) 2006-2007 Xensource Inc.
+#============================================================================
+
+
+class XendPIFMetrics:
+ """PIF Metrics."""
+
+ def __init__(self, uuid):
+ self.uuid = uuid
+
+ def set_PIF(self, pif):
+ self.pif = pif
+
+ def get_io_read_kbs(self):
+ return self._get_stat(0)
+
+ def get_io_write_kbs(self):
+ return self._get_stat(1)
+
+ def _get_stat(self, n):
+ from xen.xend.XendNode import instance as xennode
+ pifname = self.pif.device
+ pifs_util = xennode().monitor.get_pifs_util()
+ if pifname in pifs_util:
+ return pifs_util[pifname][n]
+ return 0.0
+
+ def get_record(self):
+ return {'uuid' : self.uuid,
+ 'PIF' : self.pif.uuid,
+ 'io_read_kbs' : self.get_io_read_kbs(),
+ 'io_write_kbs' : self.get_io_write_kbs()
+ }
diff --git a/tools/python/xen/xend/XendTask.py b/tools/python/xen/xend/XendTask.py
index d4de65b566..0485c39207 100644
--- a/tools/python/xen/xend/XendTask.py
+++ b/tools/python/xen/xend/XendTask.py
@@ -45,8 +45,8 @@ class XendTask(threading.Thread):
task_progress = {}
task_progress_lock = threading.Lock()
- def __init__(self, uuid, func, args, func_name, return_type = None,
- label = None, desc = None):
+ def __init__(self, uuid, func, args, func_name, return_type, label, desc,
+ session):
"""
@param uuid: UUID of the task
@type uuid: string
@@ -67,7 +67,6 @@ class XendTask(threading.Thread):
self.status = XEN_API_TASK_STATUS_TYPE[0]
self.progress = 0
- self.eta = None # TODO: we have no time estimates
self.type = return_type
self.uuid = uuid
@@ -83,6 +82,8 @@ class XendTask(threading.Thread):
self.func = func
self.args = args
+ self.session = session
+
def set_status(self, new_status):
self.status_lock.acquire()
try:
@@ -141,11 +142,12 @@ class XendTask(threading.Thread):
'name_description': self.name_description,
'status': self.status,
'progress': self.get_progress(),
- 'eta': self.eta,
'type': self.type,
'result': self.result,
'error_code': self.error_code,
'error_info': self.error_info,
+ 'allowed_operations': {},
+ 'session': self.session,
}
def get_progress(self):
diff --git a/tools/python/xen/xend/XendTaskManager.py b/tools/python/xen/xend/XendTaskManager.py
index ee5403c24a..6282078a44 100644
--- a/tools/python/xen/xend/XendTaskManager.py
+++ b/tools/python/xen/xend/XendTaskManager.py
@@ -32,7 +32,7 @@ import threading
tasks = {}
tasks_lock = threading.Lock()
-def create_task(func, args, func_name, return_type = None, label = ''):
+def create_task(func, args, func_name, return_type, label, session):
"""Creates a new Task and registers it with the XendTaskManager.
@param func: callable object XMLRPC method
@@ -48,8 +48,8 @@ def create_task(func, args, func_name, return_type = None, label = ''):
task_uuid = uuid.createString()
try:
tasks_lock.acquire()
- task = XendTask(task_uuid, func, args, func_name,
- return_type = return_type, label = label)
+ task = XendTask(task_uuid, func, args, func_name, return_type, label,
+ '', session)
tasks[task_uuid] = task
finally:
tasks_lock.release()
diff --git a/tools/python/xen/xend/XendVDI.py b/tools/python/xen/xend/XendVDI.py
index f1ea99e26b..0868814c8f 100644
--- a/tools/python/xen/xend/XendVDI.py
+++ b/tools/python/xen/xend/XendVDI.py
@@ -57,8 +57,6 @@ class XendVDI(AutoSaveObject):
'sector_size',
'virtual_size',
'physical_utilisation',
- 'parent',
- 'children',
'sharable',
'read_only']
@@ -72,8 +70,6 @@ class XendVDI(AutoSaveObject):
self.sector_size = 1024
self.virtual_size = 0
self.physical_utilisation = 0
- self.parent = None
- self.children = []
self.sharable = False
self.read_only = False
self.type = "system"
@@ -148,8 +144,6 @@ class XendVDI(AutoSaveObject):
'virtual_size': self.virtual_size,
'physical_utilisation': self.physical_utilisation,
'sector_size': self.sector_size,
- 'parent': None,
- 'children': [],
'sharable': False,
'readonly': False,
'SR': self.sr_uuid,
diff --git a/tools/python/xen/xend/image.py b/tools/python/xen/xend/image.py
index b1437d3678..eeb8bd0ebd 100644
--- a/tools/python/xen/xend/image.py
+++ b/tools/python/xen/xend/image.py
@@ -26,6 +26,7 @@ import xen.lowlevel.xc
from xen.xend.XendConstants import REVERSE_DOMAIN_SHUTDOWN_REASONS
from xen.xend.XendError import VmError, XendError
from xen.xend.XendLogging import log
+from xen.xend.XendOptions import instance as xenopts
from xen.xend.server.netif import randomMAC
from xen.xend.xenstore.xswatch import xswatch
from xen.xend import arch
@@ -340,8 +341,6 @@ class HVMImageHandler(ImageHandler):
self.pid = None
- self.dmargs += self.configVNC(imageConfig)
-
self.pae = imageConfig['hvm'].get('pae', 0)
self.apic = imageConfig['hvm'].get('apic', 0)
self.acpi = imageConfig['hvm']['devices'].get('acpi', 0)
@@ -379,8 +378,8 @@ class HVMImageHandler(ImageHandler):
dmargs = [ 'boot', 'fda', 'fdb', 'soundhw',
'localtime', 'serial', 'stdvga', 'isa',
'acpi', 'usb', 'usbdevice', 'keymap' ]
+
hvmDeviceConfig = vmConfig['image']['hvm']['devices']
-
ret = ['-vcpus', str(self.vm.getVCpuCount())]
for a in dmargs:
@@ -439,49 +438,59 @@ class HVMImageHandler(ImageHandler):
ret.append("-net")
ret.append("tap,vlan=%d,bridge=%s" % (nics, bridge))
- return ret
-
- def configVNC(self, imageConfig):
- # Handle graphics library related options
- vnc = imageConfig.get('vnc')
- sdl = imageConfig.get('sdl')
- ret = []
- nographic = imageConfig.get('nographic')
- # get password from VM config (if password omitted, None)
- vncpasswd_vmconfig = imageConfig.get('vncpasswd')
+ #
+ # Find RFB console device, and if it exists, make QEMU enable
+ # the VNC console.
+ #
+ if vmConfig['image'].get('nographic'):
+ # skip vnc init if nographic is set
+ ret.append('-nographic')
+ return ret
- if nographic:
+ vnc_config = {}
+ has_vfb = False
+ has_vnc = int(vmConfig['image'].get('vnc')) != 0
+ for dev_uuid in vmConfig['console_refs']:
+ dev_type, dev_info = vmConfig['devices'][devuuid]
+ if dev_type == 'rfb':
+ vnc_config = dev_info.get('other_config', {})
+ has_vfb = True
+ break
+
+ if not vnc_config:
+ for key in ('vncunused', 'vnclisten', 'vncdisplay', 'vncpasswd'):
+ if key in vmConfig['image']:
+ vnc_config[key] = vmConfig['image'][key]
+
+ if not has_vfb and not has_vnc:
ret.append('-nographic')
return ret
- if vnc:
- vncdisplay = imageConfig.get('vncdisplay',
- int(self.vm.getDomid()))
- vncunused = imageConfig.get('vncunused')
+
+ if not vnc_config.get('vncunused', 0) and \
+ vnc_config.get('vncdisplay', 0):
+ ret.append('-vnc')
+ ret.append(str(vncdisplay))
+ else:
+ ret.append('-vncunused')
- if vncunused:
- ret += ['-vncunused']
- else:
- ret += ['-vnc', '%d' % vncdisplay]
-
- vnclisten = imageConfig.get('vnclisten')
-
- if not(vnclisten):
- vnclisten = (xen.xend.XendOptions.instance().
- get_vnclisten_address())
- if vnclisten:
- ret += ['-vnclisten', vnclisten]
-
- vncpasswd = vncpasswd_vmconfig
- if vncpasswd is None:
- vncpasswd = (xen.xend.XendOptions.instance().
- get_vncpasswd_default())
- if vncpasswd is None:
- raise VmError('vncpasswd is not set up in ' +
- 'VMconfig and xend-config.')
- if vncpasswd != '':
- self.vm.storeVm("vncpasswd", vncpasswd)
+ vnclisten = vnc_config.get('vnclisten',
+ xenopts().get_vnclisten_address())
+ ret.append('-vnclisten')
+ ret.append(str(vnclisten))
+
+ # Store vncpassword in xenstore
+ vncpasswd = vnc_config.get('vncpasswd')
+ if not vncpasswd:
+ vncpasswd = xenopts().get_vncpasswd_default()
+
+ if vncpasswd is None:
+ raise VmError('vncpasswd is not setup in vmconfig or '
+ 'xend-config.sxp')
+
+ if vncpasswd != '':
+ self.vm.storeVm('vncpasswd', vncpasswd)
return ret
diff --git a/tools/python/xen/xend/server/ConsoleController.py b/tools/python/xen/xend/server/ConsoleController.py
index 0cccf4e55d..5afa34d7e8 100644
--- a/tools/python/xen/xend/server/ConsoleController.py
+++ b/tools/python/xen/xend/server/ConsoleController.py
@@ -8,7 +8,7 @@ class ConsoleController(DevController):
console devices with persistent UUIDs.
"""
- valid_cfg = ['uri', 'uuid', 'protocol']
+ valid_cfg = ['location', 'uuid', 'protocol']
def __init__(self, vm):
DevController.__init__(self, vm)
@@ -29,3 +29,7 @@ class ConsoleController(DevController):
def migrate(self, deviceConfig, network, dst, step, domName):
return 0
+
+ def destroyDevice(self, devid, force):
+ DevController.destroyDevice(self, devid, True)
+
diff --git a/tools/python/xen/xend/server/XMLRPCServer.py b/tools/python/xen/xend/server/XMLRPCServer.py
index 722ccb4b2b..09a66549e9 100644
--- a/tools/python/xen/xend/server/XMLRPCServer.py
+++ b/tools/python/xen/xend/server/XMLRPCServer.py
@@ -34,7 +34,7 @@ from xen.xend.XendError import XendInvalidDomain
def fixup_sxpr(sexpr):
ret = []
for k in sexpr:
- if type(k) in (types.ListType, types.TupleType):
+ if type(k) in (list, tuple):
if len(k) != 2 or k[0] != 'vcpu_avail':
ret.append(fixup_sxpr(k))
else:
diff --git a/tools/python/xen/xend/server/vfbif.py b/tools/python/xen/xend/server/vfbif.py
index 7bfe850593..0bd1b92bf3 100644
--- a/tools/python/xen/xend/server/vfbif.py
+++ b/tools/python/xen/xend/server/vfbif.py
@@ -14,7 +14,8 @@ def spawn_detached(path, args, env):
os.waitpid(p, 0)
CONFIG_ENTRIES = ['type', 'vncdisplay', 'vnclisten', 'vncpasswd', 'vncunused',
- 'display', 'xauthority', 'keymap' ]
+ 'display', 'xauthority', 'keymap',
+ 'uuid', 'location', 'protocol']
class VfbifController(DevController):
"""Virtual frame buffer controller. Handles all vfb devices for a domain.
@@ -27,10 +28,11 @@ class VfbifController(DevController):
def getDeviceDetails(self, config):
"""@see DevController.getDeviceDetails"""
- back = dict([(k, config[k]) for k in CONFIG_ENTRIES
+ back = dict([(k, str(config[k])) for k in CONFIG_ENTRIES
if config.has_key(k)])
- return (0, back, {})
+ devid = 0
+ return (devid, back, {})
def getDeviceConfiguration(self, devid):
@@ -44,6 +46,10 @@ class VfbifController(DevController):
def createDevice(self, config):
DevController.createDevice(self, config)
+ if self.vm.info.get('HVM_boot'):
+ # is HVM, so qemu-dm will handle the vfb.
+ return
+
std_args = [ "--domid", "%d" % self.vm.getDomid(),
"--title", self.vm.getName() ]
t = config.get("type", None)
@@ -82,6 +88,42 @@ class VfbifController(DevController):
else:
raise VmError('Unknown vfb type %s (%s)' % (t, repr(config)))
+
+ def waitForDevice(self, devid):
+ if self.vm.info.get('HVM_boot'):
+ log.debug('skip waiting for HVM vfb')
+ # is a qemu-dm managed device, don't wait for hotplug for these.
+ return
+
+ DevController.waitForDevice(self, devid)
+
+
+ def reconfigureDevice(self, _, config):
+ """ Only allow appending location information of vnc port into
+ xenstore."""
+
+ if 'location' in config:
+ (devid, back, front) = self.getDeviceDetails(config)
+ self.writeBackend(devid, 'location', config['location'])
+ return back.get('uuid')
+
+ raise VmError('Refusing to reconfigure device vfb:%d' % devid)
+
+ def destroyDevice(self, devid, force):
+ if self.vm.info.get('HVM_boot'):
+ # remove the backend xenstore entries for HVM guests no matter
+ # what
+ DevController.destroyDevice(self, devid, True)
+ else:
+ DevController.destroyDevice(self, devid, force)
+
+
+ def migrate(self, deviceConfig, network, dst, step, domName):
+ if self.vm.info.get('HVM_boot'):
+ return 0
+ return DevController.migrate(self, deviceConfig, network, dst, step,
+ domName)
+
class VkbdifController(DevController):
"""Virtual keyboard controller. Handles all vkbd devices for a domain.
"""
@@ -92,3 +134,24 @@ class VkbdifController(DevController):
back = {}
front = {}
return (devid, back, front)
+
+ def waitForDevice(self, config):
+ if self.vm.info.get('HVM_boot'):
+ # is a qemu-dm managed device, don't wait for hotplug for these.
+ return
+
+ DevController.waitForDevice(self, config)
+
+ def destroyDevice(self, devid, force):
+ if self.vm.info.get('HVM_boot'):
+ # remove the backend xenstore entries for HVM guests no matter
+ # what
+ DevController.destroyDevice(self, devid, True)
+ else:
+ DevController.destroyDevice(self, devid, force)
+
+ def migrate(self, deviceConfig, network, dst, step, domName):
+ if self.vm.info.get('HVM_boot'):
+ return 0
+ return DevController.migrate(self, deviceConfig, network, dst, step,
+ domName)
diff --git a/tools/python/xen/xm/create.py b/tools/python/xen/xm/create.py
index ac90ff177c..450e3283d1 100644
--- a/tools/python/xen/xm/create.py
+++ b/tools/python/xen/xm/create.py
@@ -594,9 +594,9 @@ def configure_vfbs(config_devs, vals):
'xauthority', 'type', 'vncpasswd' ]:
err("configuration option %s unknown to vfbs" % k)
config.append([k,v])
- for n in iter(dir(vals)):
- if n == "keymap":
- config.append(['keymap',vals.keymap])
+ if not d.has_key("keymap"):
+ if vals.keymap:
+ config.append(['keymap',vals.keymap])
if not d.has_key("display") and os.environ.has_key("DISPLAY"):
config.append(["display", os.environ['DISPLAY']])
if not d.has_key("xauthority"):
diff --git a/tools/python/xen/xm/messages/en/xen-xm.po b/tools/python/xen/xm/messages/en/xen-xm.po
index ff4b4ea75b..d422b2e6b8 100644
--- a/tools/python/xen/xm/messages/en/xen-xm.po
+++ b/tools/python/xen/xm/messages/en/xen-xm.po
@@ -12,14 +12,14 @@
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# ============================================================================
-# Copyright (c) 2006 XenSource Inc.
+# Copyright (c) 2006-2007 XenSource Inc.
# ============================================================================
#
#
msgid ""
msgstr ""
"Project-Id-Version: Xen-xm 3.0\n"
-"PO-Revision-Date: 2006-12-28 15:43+0000\n"
+"PO-Revision-Date: 2007-01-30 17:15+0000\n"
"Last-Translator: Ewan Mellor <ewan@xensource.com>\n"
"Language-Team: xen-devel <xen-devel@lists.xensource.com>\n"
"MIME-Version: 1.0\n"
@@ -47,9 +47,21 @@ msgstr "The host_cpu handle %(1)s is invalid."
msgid "HOST_HANDLE_INVALID"
msgstr "The host handle %(1)s is invalid."
+msgid "HOST_METRICS_HANDLE_INVALID"
+msgstr "The host_metrics handle %(1)s is invalid."
+
+msgid "PIF_HANDLE_INVALID"
+msgstr "The PIF handle %(1)s is invalid."
+
+msgid "PIF_METRICS_HANDLE_INVALID"
+msgstr "The PIF_METRICS handle %(1)s is invalid."
+
msgid "SR_HANDLE_INVALID"
msgstr "The SR handle %(1)s is invalid."
+msgid "TASK_HANDLE_INVALID"
+msgstr "The task handle %(1)s is invalid."
+
msgid "VBD_HANDLE_INVALID"
msgstr "The VBD handle %(1)s is invalid."
@@ -62,11 +74,23 @@ msgstr "The VIF handle %(1)s is invalid."
msgid "VM_HANDLE_INVALID"
msgstr "The VM handle %(1)s is invalid."
+msgid "VM_METRICS_HANDLE_INVALID"
+msgstr "The VM_metrics handle %(1)s is invalid."
+
msgid "VTPM_HANDLE_INVALID"
msgstr "The VTPM handle %(1)s is invalid."
+msgid "OPERATION_NOT_ALLOWED"
+msgstr "You attempted an operation that was not allowed."
+
msgid "NETWORK_ALREADY_CONNECTED"
msgstr "The network you specified already has a PIF attached to it, and so another one may not be attached."
+msgid "PIF_IS_PHYSICAL"
+msgstr "The PIF %(1)s corresponds to a physical interface, and so may not be destroyed."
+
+msgid "VLAN_TAG_INVALID"
+msgstr "The VLAN tag you gave (%(1)s) is invalid -- it must be between 0 and 4095."
+
msgid "VM_BAD_POWER_STATE"
msgstr "The VM must be %(2)s to perform the requested operation (it is currently %(3)s)."
diff --git a/tools/security/Makefile b/tools/security/Makefile
index cd0835a910..d29a1926bb 100644
--- a/tools/security/Makefile
+++ b/tools/security/Makefile
@@ -86,7 +86,7 @@ install:
endif
.PHONY: build
-build: mk-symlinks $(ACM_INST_TOOLS) $(ACM_NOINST_TOOLS)
+build: $(ACM_INST_TOOLS) $(ACM_NOINST_TOOLS)
python python/setup.py build
chmod 700 $(ACM_SCRIPTS)
@@ -104,7 +104,6 @@ clean:
$(RM) $(ACM_INST_TOOLS) $(ACM_NOINST_TOOLS)
$(RM) $(ACM_OBJS)
$(RM) $(PROG_DEPS)
- $(RM) -r xen
$(RM) -r build
.PHONY: mrproper
diff --git a/tools/xenfb/Makefile b/tools/xenfb/Makefile
index e7c76e73b5..b9bd3ba1e6 100644
--- a/tools/xenfb/Makefile
+++ b/tools/xenfb/Makefile
@@ -12,7 +12,7 @@ INSTALL_DIR = $(INSTALL) -d -m0755
all: build
.PHONY: build
-build: mk-symlinks
+build:
$(MAKE) vncfb sdlfb
install: all
diff --git a/tools/xm-test/tests/vtpm/09_vtpm-xapi.py b/tools/xm-test/tests/vtpm/09_vtpm-xapi.py
index 89975d077f..4798dc13c6 100644
--- a/tools/xm-test/tests/vtpm/09_vtpm-xapi.py
+++ b/tools/xm-test/tests/vtpm/09_vtpm-xapi.py
@@ -4,14 +4,22 @@
# Author: Stefan Berger <stefanb@us.ibm.com>
# Test to test the vtpm class through the Xen-API
+#
+# Tested methods:
+# VTPM: get_uuid, get_backend, get_by_uuid, get_record
+# create, destroy, get_VM
+# VM: get_VTPMS
from XmTestLib import xapi
from XmTestLib.XenAPIDomain import XmTestAPIDomain
from XmTestLib import *
+from xen.xend import XendDomain
from vtpm_utils import *
import commands
import os
+VTPM_RECORD_KEYS = [ 'backend', 'VM', 'uuid' ]
+
try:
# XmTestAPIDomain tries to establish a connection to XenD
domain = XmTestAPIDomain()
@@ -20,52 +28,131 @@ except Exception, e:
vm_uuid = domain.get_uuid()
vtpmcfg = {}
-vtpmcfg['type'] = "paravirtualised"
-vtpmcfg['backend'] = "Domain-0"
-vtpmcfg['instance'] = 1
+vtpmcfg['backend'] = XendDomain.DOM0_UUID
vtpmcfg['VM'] = vm_uuid
session = xapi.connect()
vtpm_uuid = session.xenapi.VTPM.create(vtpmcfg)
-vtpm_id = session.xenapi.VTPM.get_instance(vtpm_uuid)
vtpm_be = session.xenapi.VTPM.get_backend(vtpm_uuid)
if vtpm_be != vtpmcfg['backend']:
FAIL("vTPM's backend is in '%s', expected: '%s'" %
(vtpm_be, vtpmcfg['backend']))
-driver = session.xenapi.VTPM.get_driver(vtpm_uuid)
-if driver != vtpmcfg['type']:
- FAIL("vTPM has driver type '%s', expected: '%s'" %
- (driver, vtpmcfg['type']))
-
vtpm_rec = session.xenapi.VTPM.get_record(vtpm_uuid)
-if vtpm_rec['driver'] != vtpmcfg['type']:
- FAIL("vTPM record shows driver type '%s', expected: '%s'" %
- (vtpm_rec['driver'], vtpmcfg['type']))
+miss_keys = []
+for k in VTPM_RECORD_KEYS:
+ if k not in vtpm_rec.keys():
+ miss_keys.append(k)
+if len(miss_keys) > 0:
+ FAIL("vTPM record is missing key(s): %s" % miss_keys)
+
if vtpm_rec['uuid'] != vtpm_uuid:
FAIL("vTPM record shows vtpm uuid '%s', expected: '%s'" %
(vtpm_rec['uuid'], vtpm_uuid))
if vtpm_rec['VM'] != vm_uuid:
FAIL("vTPM record shows VM uuid '%s', expected: '%s'" %
(vtpm_rec['VM'], vm_uuid))
+if vtpm_rec['backend'] != vtpmcfg['backend']:
+ FAIL("vTPM record shows VM bakcned '%s', expected: '%s'" %
+ (vtpm_rev['backend'], vtpmcfg['backend']))
+
+badkeys = []
+keys = vtpm_rec.keys()
+for k in keys:
+ if k not in VTPM_RECORD_KEYS:
+ badkeys.append(k)
+if len(badkeys) > 0:
+ FAIL("Unexpected attributes in result: %s" % badkeys)
+
+if vm_uuid != session.xenapi.VTPM.get_VM(vtpm_uuid):
+ FAIL("VM uuid from VTPM.get_VM different (%s) than expected (%s)." %
+ (vm_ref, vm_uuid))
+
+uuid = session.xenapi.VTPM.get_uuid(vtpm_uuid)
+if uuid != vtpm_uuid:
+ FAIL("vTPM from VTPM.get_uuid different (%s) than expected (%s)." %
+ (uuid, vtpm_uuid))
+
+vtpm_ref = session.xenapi.VTPM.get_by_uuid(vtpm_uuid)
+if vtpm_ref != vtpm_uuid:
+ FAIL("vTPM from VTPM.get_by_uuid different (%s) than expected (%s)." %
+ (vtpm_ref, vtpm_uuid))
+
+vm_vtpms = session.xenapi.VM.get_VTPMs(vm_uuid)
+if len(vm_vtpms) != 1:
+ FAIL("Number of vTPMs from get_VTPMs is (%d) not what was expected (%d)" %
+ (len(vm_vtpms), 1))
+if vtpm_uuid not in vm_vtpms:
+ FAIL("Other vTPM uuid (%s) returned from VM.get_VTPMs than expected (%s)" %
+ (vm_vtpms[0], vtpm_uuid))
-success = domain.start()
+try:
+ console = domain.start()
+except DomainError, e:
+ FAIL("Unable to create domain (%s)" % domName)
-console = domain.getConsole()
+try:
+ console.sendInput("input")
+except ConsoleError, e:
+ saveLog(console.getHistory())
+ FAIL(str(e))
try:
run = console.runCmd("cat /sys/devices/xen/vtpm-0/pcrs")
except ConsoleError, e:
saveLog(console.getHistory())
- vtpm_cleanup(domName)
- FAIL("No result from dumping the PCRs")
+ FAIL("1. No result from dumping the PCRs")
if re.search("No such file",run["output"]):
- vtpm_cleanup(domName)
FAIL("TPM frontend support not compiled into (domU?) kernel")
+if not re.search("PCR-00:",run["output"]):
+ saveLog(console.getHistory())
+ FAIL("1. Virtual TPM is not working correctly on /dev/vtpm on backend side: \n%s" % run["output"])
+
+try:
+ rc = session.xenapi.VTPM.destroy(vtpm_uuid)
+ #Should never get here
+ FAIL("Could destroy vTPM while VM is running")
+except:
+ pass
+
+rc = session.xenapi.VM.suspend(vm_uuid)
+if rc:
+ FAIL("Could not suspend VM")
+
+try:
+ rc = session.xenapi.VTPM.destroy(vtpm_uuid)
+ #May not throw an exception in 'suspend' state
+except:
+ pass
+
+rc = session.xenapi.VM.resume(vm_uuid, False)
+if rc:
+ FAIL("Could not resume VM")
+
+try:
+ console = domain.getConsole()
+except ConsoleError, e:
+ FAIL(str(e))
+
+try:
+ run = console.runCmd("cat /sys/devices/xen/vtpm-0/pcrs")
+except ConsoleError, e:
+ saveLog(console.getHistory())
+ FAIL("2. No result from dumping the PCRs. vTPM has been removed?")
+
+if not re.search("PCR-00:",run["output"]):
+ saveLog(console.getHistory())
+ FAIL("2. Virtual TPM is not working correctly on /dev/vtpm on backend side: \n%s" % run["output"])
+
domain.stop()
+
+rc = session.xenapi.VTPM.destroy(vtpm_uuid)
+if not rc:
+ FAIL("Could NOT destroy vTPM while domain is halted.")
+
domain.destroy()