mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 02:01:24 +01:00
tools/xenstored: use new stable interface instead of libxenctrl
Replace the current use of the unstable xc_domain_getinfo_single() interface with the stable domctl XEN_DOMCTL_get_domain_state call via the new libxenmanage library. This will remove the last usage of libxenctrl by Xenstore, so update the library dependencies accordingly. For now only do a direct replacement without using the functionality of obtaining information about domains having changed the state. Signed-off-by: Juergen Gross <jgross@suse.com> Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org> Reviewed-by: Anthony PERARD <anthony.perard@vates.tech>
This commit is contained in:
1 parent
e995055d69
commit
42630ceddf
8 files changed
+28
-40
No files matched your search
+4
-4
@@ -308,7 +308,7 @@ endif
|
|||||||
# libraries under tools/libs
|
# libraries under tools/libs
|
||||||
#######
|
#######
|
||||||
|
|
||||||
STUB_LIBS := toolcore toollog evtchn gnttab call foreignmemory devicemodel ctrl guest
|
STUB_LIBS := toolcore toollog evtchn gnttab call foreignmemory devicemodel ctrl guest manage
|
||||||
|
|
||||||
LIBDEP_guest := cross-zlib
|
LIBDEP_guest := cross-zlib
|
||||||
|
|
||||||
@@ -466,7 +466,7 @@ grub: cross-polarssl grub-upstream $(CROSS_ROOT) grub-$(XEN_TARGET_ARCH)-minios-
|
|||||||
# xenstore
|
# xenstore
|
||||||
##########
|
##########
|
||||||
|
|
||||||
xenstore-minios.gen.cfg: APP_LIBS = gnttab evtchn toollog ctrl
|
xenstore-minios.gen.cfg: APP_LIBS = gnttab evtchn toollog manage
|
||||||
xenstore-minios.gen.cfg: xenstore-minios.cfg Makefile
|
xenstore-minios.gen.cfg: xenstore-minios.cfg Makefile
|
||||||
$(GEN_config) >$@
|
$(GEN_config) >$@
|
||||||
|
|
||||||
@@ -481,7 +481,7 @@ xenstore: $(CROSS_ROOT) xenstore-minios-config.mk
|
|||||||
# xenstorepvh
|
# xenstorepvh
|
||||||
#############
|
#############
|
||||||
|
|
||||||
xenstorepvh-minios.gen.cfg: APP_LIBS = gnttab evtchn toollog ctrl
|
xenstorepvh-minios.gen.cfg: APP_LIBS = gnttab evtchn toollog manage
|
||||||
xenstorepvh-minios.gen.cfg: xenstorepvh-minios.cfg Makefile
|
xenstorepvh-minios.gen.cfg: xenstorepvh-minios.cfg Makefile
|
||||||
$(GEN_config) >$@
|
$(GEN_config) >$@
|
||||||
|
|
||||||
@@ -524,7 +524,7 @@ else
|
|||||||
pv-grub-if-enabled:
|
pv-grub-if-enabled:
|
||||||
endif
|
endif
|
||||||
|
|
||||||
XENSTORE_DEPS := libxenevtchn libxengnttab libxenctrl
|
XENSTORE_DEPS := libxenevtchn libxengnttab libxenmanage
|
||||||
|
|
||||||
.PHONY: xenstore-stubdom
|
.PHONY: xenstore-stubdom
|
||||||
xenstore-stubdom: mini-os-$(XEN_TARGET_ARCH)-xenstore $(XENSTORE_DEPS) xenstore
|
xenstore-stubdom: mini-os-$(XEN_TARGET_ARCH)-xenstore $(XENSTORE_DEPS) xenstore
|
||||||
|
|||||||
@@ -13,5 +13,6 @@ GNTTAB_PATH = $(XEN_ROOT)/stubdom/libs-$(MINIOS_TARGET_ARCH)/gnttab
|
|||||||
CALL_PATH = $(XEN_ROOT)/stubdom/libs-$(MINIOS_TARGET_ARCH)/call
|
CALL_PATH = $(XEN_ROOT)/stubdom/libs-$(MINIOS_TARGET_ARCH)/call
|
||||||
FOREIGNMEMORY_PATH = $(XEN_ROOT)/stubdom/libs-$(MINIOS_TARGET_ARCH)/foreignmemory
|
FOREIGNMEMORY_PATH = $(XEN_ROOT)/stubdom/libs-$(MINIOS_TARGET_ARCH)/foreignmemory
|
||||||
DEVICEMODEL_PATH = $(XEN_ROOT)/stubdom/libs-$(MINIOS_TARGET_ARCH)/devicemodel
|
DEVICEMODEL_PATH = $(XEN_ROOT)/stubdom/libs-$(MINIOS_TARGET_ARCH)/devicemodel
|
||||||
|
MANAGE_PATH = $(XEN_ROOT)/stubdom/libs-$(MINIOS_TARGET_ARCH)/manage
|
||||||
CTRL_PATH = $(XEN_ROOT)/stubdom/libs-$(MINIOS_TARGET_ARCH)/ctrl
|
CTRL_PATH = $(XEN_ROOT)/stubdom/libs-$(MINIOS_TARGET_ARCH)/ctrl
|
||||||
GUEST_PATH = $(XEN_ROOT)/stubdom/libs-$(MINIOS_TARGET_ARCH)/guest
|
GUEST_PATH = $(XEN_ROOT)/stubdom/libs-$(MINIOS_TARGET_ARCH)/guest
|
||||||
@@ -5,7 +5,7 @@ include Makefile.common
|
|||||||
|
|
||||||
xenstored: LDLIBS += $(LDLIBS_libxenevtchn)
|
xenstored: LDLIBS += $(LDLIBS_libxenevtchn)
|
||||||
xenstored: LDLIBS += $(LDLIBS_libxengnttab)
|
xenstored: LDLIBS += $(LDLIBS_libxengnttab)
|
||||||
xenstored: LDLIBS += $(LDLIBS_libxenctrl)
|
xenstored: LDLIBS += $(LDLIBS_libxenmanage)
|
||||||
xenstored: LDLIBS += -lrt
|
xenstored: LDLIBS += -lrt
|
||||||
xenstored: LDLIBS += $(SOCKET_LIBS)
|
xenstored: LDLIBS += $(SOCKET_LIBS)
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ XENSTORED_OBJS-$(CONFIG_MiniOS) += minios.o lu_minios.o
|
|||||||
# Include configure output (config.h)
|
# Include configure output (config.h)
|
||||||
CFLAGS += -include $(XEN_ROOT)/tools/config.h
|
CFLAGS += -include $(XEN_ROOT)/tools/config.h
|
||||||
CFLAGS += $(CFLAGS_libxenevtchn)
|
CFLAGS += $(CFLAGS_libxenevtchn)
|
||||||
CFLAGS += $(CFLAGS_libxenctrl)
|
CFLAGS += $(CFLAGS_libxenmanage)
|
||||||
CFLAGS += $(CFLAGS_libxentoolcore)
|
CFLAGS += $(CFLAGS_libxentoolcore)
|
||||||
|
|
||||||
$(XENSTORED_OBJS-y): CFLAGS += $(CFLAGS_libxengnttab)
|
$(XENSTORED_OBJS-y): CFLAGS += $(CFLAGS_libxengnttab)
|
||||||
|
|||||||
@@ -19,7 +19,6 @@
|
|||||||
#ifndef _XENSTORED_CORE_H
|
#ifndef _XENSTORED_CORE_H
|
||||||
#define _XENSTORED_CORE_H
|
#define _XENSTORED_CORE_H
|
||||||
|
|
||||||
#include <xenctrl.h>
|
|
||||||
#include <xengnttab.h>
|
#include <xengnttab.h>
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|||||||
+19
-33
@@ -34,14 +34,15 @@
|
|||||||
#include "control.h"
|
#include "control.h"
|
||||||
|
|
||||||
#include <xenevtchn.h>
|
#include <xenevtchn.h>
|
||||||
#include <xenctrl.h>
|
#include <xenmanage.h>
|
||||||
|
#include <xen-barrier.h>
|
||||||
#include <xen/grant_table.h>
|
#include <xen/grant_table.h>
|
||||||
|
|
||||||
#ifdef __MINIOS__
|
#ifdef __MINIOS__
|
||||||
#include <mini-os/xenbus.h>
|
#include <mini-os/xenbus.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static xc_interface **xc_handle;
|
static xenmanage_handle *xm_handle;
|
||||||
xengnttab_handle **xgt_handle;
|
xengnttab_handle **xgt_handle;
|
||||||
static evtchn_port_t virq_port;
|
static evtchn_port_t virq_port;
|
||||||
|
|
||||||
@@ -619,32 +620,28 @@ static int destroy_domain(void *_domain)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool get_domain_info(unsigned int domid, xc_domaininfo_t *dominfo)
|
|
||||||
{
|
|
||||||
return xc_domain_getinfo_single(*xc_handle, domid, dominfo) == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int check_domain(const void *k, void *v, void *arg)
|
static int check_domain(const void *k, void *v, void *arg)
|
||||||
{
|
{
|
||||||
xc_domaininfo_t dominfo;
|
unsigned int state;
|
||||||
struct connection *conn;
|
struct connection *conn;
|
||||||
bool dom_valid;
|
int dom_invalid;
|
||||||
struct domain *domain = v;
|
struct domain *domain = v;
|
||||||
bool *notify = arg;
|
bool *notify = arg;
|
||||||
|
|
||||||
dom_valid = get_domain_info(domain->domid, &dominfo);
|
dom_invalid = xenmanage_get_domain_info(xm_handle, domain->domid,
|
||||||
|
&state, NULL);
|
||||||
if (!domain->introduced) {
|
if (!domain->introduced) {
|
||||||
if (!dom_valid)
|
if (dom_invalid)
|
||||||
talloc_free(domain);
|
talloc_free(domain);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (dom_valid) {
|
if (!dom_invalid) {
|
||||||
if ((dominfo.flags & XEN_DOMINF_shutdown)
|
if ((state & XENMANAGE_GETDOMSTATE_STATE_SHUTDOWN)
|
||||||
&& !domain->shutdown) {
|
&& !domain->shutdown) {
|
||||||
domain->shutdown = true;
|
domain->shutdown = true;
|
||||||
*notify = true;
|
*notify = true;
|
||||||
}
|
}
|
||||||
if (!(dominfo.flags & XEN_DOMINF_dying))
|
if (!(state & XENMANAGE_GETDOMSTATE_STATE_DEAD))
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (domain->conn) {
|
if (domain->conn) {
|
||||||
@@ -786,10 +783,9 @@ static struct domain *find_or_alloc_domain(const void *ctx, unsigned int domid)
|
|||||||
static struct domain *find_or_alloc_existing_domain(unsigned int domid)
|
static struct domain *find_or_alloc_existing_domain(unsigned int domid)
|
||||||
{
|
{
|
||||||
struct domain *domain;
|
struct domain *domain;
|
||||||
xc_domaininfo_t dominfo;
|
|
||||||
|
|
||||||
domain = find_domain_struct(domid);
|
domain = find_domain_struct(domid);
|
||||||
if (!domain && get_domain_info(domid, &dominfo))
|
if (!domain && !xenmanage_get_domain_info(xm_handle, domid, NULL, NULL))
|
||||||
domain = alloc_domain(NULL, domid);
|
domain = alloc_domain(NULL, domid);
|
||||||
|
|
||||||
return domain;
|
return domain;
|
||||||
@@ -1187,12 +1183,6 @@ int do_reset_watches(const void *ctx, struct connection *conn,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int close_xc_handle(void *_handle)
|
|
||||||
{
|
|
||||||
xc_interface_close(*(xc_interface**)_handle);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int close_xgt_handle(void *_handle)
|
static int close_xgt_handle(void *_handle)
|
||||||
{
|
{
|
||||||
xengnttab_close(*(xengnttab_handle **)_handle);
|
xengnttab_close(*(xengnttab_handle **)_handle);
|
||||||
@@ -1258,15 +1248,9 @@ void domain_early_init(void)
|
|||||||
if (!domhash)
|
if (!domhash)
|
||||||
barf_perror("Failed to allocate domain hashtable");
|
barf_perror("Failed to allocate domain hashtable");
|
||||||
|
|
||||||
xc_handle = talloc(talloc_autofree_context(), xc_interface*);
|
xm_handle = xenmanage_open(NULL, 0);
|
||||||
if (!xc_handle)
|
if (!xm_handle)
|
||||||
barf_perror("Failed to allocate domain handle");
|
barf_perror("Failed to open connection to libxenmanage");
|
||||||
|
|
||||||
*xc_handle = xc_interface_open(0,0,0);
|
|
||||||
if (!*xc_handle)
|
|
||||||
barf_perror("Failed to open connection to hypervisor");
|
|
||||||
|
|
||||||
talloc_set_destructor(xc_handle, close_xc_handle);
|
|
||||||
|
|
||||||
xgt_handle = talloc(talloc_autofree_context(), xengnttab_handle*);
|
xgt_handle = talloc(talloc_autofree_context(), xengnttab_handle*);
|
||||||
if (!xgt_handle)
|
if (!xgt_handle)
|
||||||
@@ -1306,6 +1290,8 @@ void domain_deinit(void)
|
|||||||
{
|
{
|
||||||
if (virq_port)
|
if (virq_port)
|
||||||
xenevtchn_unbind(xce_handle, virq_port);
|
xenevtchn_unbind(xce_handle, virq_port);
|
||||||
|
|
||||||
|
xenmanage_close(xm_handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1335,13 +1321,13 @@ int domain_alloc_permrefs(struct node_perms *perms)
|
|||||||
{
|
{
|
||||||
unsigned int i, domid;
|
unsigned int i, domid;
|
||||||
struct domain *d;
|
struct domain *d;
|
||||||
xc_domaininfo_t dominfo;
|
|
||||||
|
|
||||||
for (i = 0; i < perms->num; i++) {
|
for (i = 0; i < perms->num; i++) {
|
||||||
domid = perms->p[i].id;
|
domid = perms->p[i].id;
|
||||||
d = find_domain_struct(domid);
|
d = find_domain_struct(domid);
|
||||||
if (!d) {
|
if (!d) {
|
||||||
if (!get_domain_info(domid, &dominfo))
|
if (xenmanage_get_domain_info(xm_handle, domid,
|
||||||
|
NULL, NULL))
|
||||||
perms->p[i].perms |= XS_PERM_IGNORE;
|
perms->p[i].perms |= XS_PERM_IGNORE;
|
||||||
else if (!alloc_domain(NULL, domid))
|
else if (!alloc_domain(NULL, domid))
|
||||||
return ENOMEM;
|
return ENOMEM;
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <syslog.h>
|
#include <syslog.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
#include <unistd.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <syslog.h>
|
#include <syslog.h>
|
||||||
|
#include <unistd.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#include "talloc.h"
|
#include "talloc.h"
|
||||||
|
|||||||