xen/xl-check-for-libvirt-managed-domain.patch
Charles Arnold 66e0c5e297 - When the xl command is used, check to see if the domain being
modified is managed by libvirt and print warning if it is.
  xl-check-for-libvirt-managed-domain.patch

- Upstream patches from Jan
  53455585-x86-AMD-feature-masking-is-unavailable-on-Fam11.patch
  5346a7a0-x86-AMD-support-further-feature-masking-MSRs.patch
  534bbd90-x86-nested-HAP-don-t-BUG-on-legitimate-error.patch
  534bdf47-x86-HAP-also-flush-TLB-when-altering-a-present-1G-or-intermediate-entry.patch
  53563ea4-x86-MSI-drop-workaround-for-insecure-Dom0-kernels.patch
  5357baff-x86-add-missing-break-in-dom0_pit_access.patch
- XSA-92
  xsa92.patch 

- Add # needssslcertforbuild to use the project's certificate when
  building in a home project. (bnc#872354)

OBS-URL: https://build.opensuse.org/package/show/Virtualization/xen?expand=0&rev=312
2014-05-01 03:35:21 +00:00

69 lines
2.1 KiB
Diff

Index: xen-4.4.0-testing/tools/libxl/xl.c
===================================================================
--- xen-4.4.0-testing.orig/tools/libxl/xl.c
+++ xen-4.4.0-testing/tools/libxl/xl.c
@@ -282,6 +282,44 @@ static void xl_ctx_free(void)
}
}
+/*
+ Return 0 if domain is managed by libvirt
+*/
+static int xl_lookup_libvirt_managed_domains(int argc, char **argv)
+{
+ FILE *fp;
+ int i;
+ char line[1024];
+ char *libvirt_sock = "/run/libvirt/libvirt-sock";
+
+ /* Check for the libvirt socket file */
+ if (access(libvirt_sock, F_OK) != 0) {
+ return 1;
+ }
+
+ /* Run virsh to get a list of running domains managed by libvirt */
+ fp = popen("/usr/bin/virsh list --name 2>&1", "r");
+ if (fp == NULL) {
+ return 1;
+ }
+
+ /* Read the list of domains looking for each name in the xl command */
+ while (fgets(line, sizeof(line)-1, fp) != NULL) {
+ line[strlen(line)-1] = '\0';
+ for (i=0; i<argc && line[0]; ++i) {
+ if (!strcmp(argv[i], line)) {
+ pclose(fp);
+ return 0;
+ }
+ }
+ }
+
+ pclose(fp);
+
+ /* Not found */
+ return 1;
+}
+
int main(int argc, char **argv)
{
int opt = 0;
@@ -345,6 +383,18 @@ int main(int argc, char **argv)
goto xit;
}
if (cspec->modifies && !dryrun_only) {
+ if (!force_execution) {
+ if (!xl_lookup_libvirt_managed_domains(argc, argv)) {
+ fprintf(stderr,
+"Warning: This domain is managed by libvirt. Using xl commands to modify this\n"
+"domain will result in errors when virsh or virt-manager is used.\n"
+"Please use only virsh or virt-manager to manage this domain.\n\n"
+"(This check can be overridden with the -f option.)\n"
+ );
+ ret = 1;
+ goto xit;
+ }
+ }
for (int i = 0; i < sizeof(locks)/sizeof(locks[0]); i++) {
if (!access(locks[i], F_OK) && !force_execution) {
fprintf(stderr,