#include "logging.h"
#include "uuid.h"
#include "configmake.h"
+#include "lxc_container.h"
#define VIR_FROM_THIS VIR_FROM_LXC
struct utsname utsname;
virCapsPtr caps;
virCapsGuestPtr guest;
+ const char *altArch;
uname(&utsname);
if ((guest = virCapabilitiesAddGuest(caps,
"exe",
utsname.machine,
- sizeof(int) == 4 ? 32 : 8,
+ sizeof(void*) == 4 ? 32 : 64,
LIBEXECDIR "/libvirt_lxc",
NULL,
0,
NULL) == NULL)
goto error;
+ /* On 64-bit hosts, we can use personality() to request a 32bit process */
+ if ((altArch = lxcContainerGetAlt32bitArch(utsname.machine)) != NULL) {
+ if ((guest = virCapabilitiesAddGuest(caps,
+ "exe",
+ altArch,
+ 32,
+ LIBEXECDIR "/libvirt_lxc",
+ NULL,
+ 0,
+ NULL)) == NULL)
+ goto error;
+
+ if (virCapabilitiesAddGuestDomain(guest,
+ "lxc",
+ NULL,
+ NULL,
+ 0,
+ NULL) == NULL)
+ goto error;
+ }
+
/* LXC Requires an emulator in the XML */
virCapabilitiesSetEmulatorRequired(caps);
#endif
}
+const char *lxcContainerGetAlt32bitArch(const char *arch)
+{
+ /* Any Linux 64bit arch which has a 32bit
+ * personality available should be listed here */
+ if (STREQ(arch, "x86_64"))
+ return "i686";
+ if (STREQ(arch, "s390x"))
+ return "s390";
+ if (STREQ(arch, "ppc64"))
+ return "ppc";
+ if (STREQ(arch, "parisc64"))
+ return "parisc";
+ if (STREQ(arch, "sparc64"))
+ return "sparc";
+ if (STREQ(arch, "mips64"))
+ return "mips";
+
+ return NULL;
+}
+
+
/**
* lxcContainerStart:
* @def: pointer to virtual machine structure
int lxcContainerAvailable(int features);
+const char *lxcContainerGetAlt32bitArch(const char *arch);
+
#endif /* LXC_CONTAINER_H */
/*
- * Copyright (C) 2010 Red Hat, Inc.
- * Copyright IBM Corp. 2008
+ * Copyright (C) 2010 Red Hat, Inc. Copyright IBM Corp. 2008
*
* lxc_controller.c: linux container process controller
*
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/un.h>
+#include <sys/utsname.h>
+#include <sys/personality.h>
#include <unistd.h>
#include <paths.h>
#include <fcntl.h>
return 0;
}
+static int lxcSetPersonality(virDomainDefPtr def)
+{
+ struct utsname utsname;
+ const char *altArch;
+
+ uname(&utsname);
+
+ altArch = lxcContainerGetAlt32bitArch(utsname.machine);
+ if (altArch &&
+ STREQ(def->os.arch, altArch)) {
+ if (personality(PER_LINUX32) < 0) {
+ virReportSystemError(errno, _("Unable to request personality for %s on %s"),
+ altArch, utsname.machine);
+ return -1;
+ }
+ }
+ return 0;
+}
+
#ifndef MS_REC
# define MS_REC 16384
#endif
}
}
+ if (lxcSetPersonality(def) < 0)
+ goto cleanup;
if ((container = lxcContainerStart(def,
nveths,