From nobody Sat May 4 19:14:25 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1531799647959535.4146151477881; Mon, 16 Jul 2018 20:54:07 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 21E6781DE3; Tue, 17 Jul 2018 03:54:05 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 76EB1608EE; Tue, 17 Jul 2018 03:54:02 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 6469618052EA; Tue, 17 Jul 2018 03:53:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w6H3r7jo029347 for ; Mon, 16 Jul 2018 23:53:07 -0400 Received: by smtp.corp.redhat.com (Postfix) id 203EE60C4E; Tue, 17 Jul 2018 03:53:07 +0000 (UTC) Received: from mx1.redhat.com (ext-mx19.extmail.prod.ext.phx2.redhat.com [10.5.110.48]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 17FD560BE4 for ; Tue, 17 Jul 2018 03:53:03 +0000 (UTC) Received: from mail-vk0-f47.google.com (mail-vk0-f47.google.com [209.85.213.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8CF86307D861 for ; Tue, 17 Jul 2018 03:52:52 +0000 (UTC) Received: by mail-vk0-f47.google.com with SMTP id e139-v6so21381392vkf.6 for ; Mon, 16 Jul 2018 20:52:52 -0700 (PDT) Received: from localhost.localdomain ([187.107.181.94]) by smtp.gmail.com with ESMTPSA id h23-v6sm36886vke.13.2018.07.16.20.52.49 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Jul 2018 20:52:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id; bh=a4nkX49Afb+No8dgL151LmE/ncXowiT6Hm4mEr/n+Ac=; b=Vc2TJ/LAviSnk8iH7VdlNq2HN5L2aHUkW6Iax3DWMzFdW1Ziik7g/iN7uDdak22x7i jsrX8WXga+4EmgWJVlPm7NCqUJIhckg5u1+IDm1glTevYB7tlEjfmjV8XU+9AfrfGaK3 hsUqAK1i3g9JpKbz52kNSJxQ88Gfs8fnqP6LPmOwKx/k1DlcRye89SeGvkscVvJjqu5L U2z3LJ6H1oKZTUCnUPYeWLwGZb7ScOxWoTdcKz8xWWT6Xh/9CnACcDiHfMUeo8dhY58y lnwIAn90MOcORxaNHaM0SEvVFTu7Eft4KSQBkdR45/0rO8ouv+oJbNBaR8pLjDjCU/kM 0W+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id; bh=a4nkX49Afb+No8dgL151LmE/ncXowiT6Hm4mEr/n+Ac=; b=q8ePcwtJY64I/gKOkDTbt0vQz0RI+ikCB2duERnz9oc8rU0SZ4jyQ2MnEXEbwT3tf2 c3LW5XXDdC2Wjv3+k9Yte2bqV3r/CBWSD93AHN0ucuvGVJWzYWv0bdMZug4tTRRZyDsa 1nUMNVpHtQmvkcVCFF7xFHQpfvEi8bQgUUQSKHhzhezXTW7rixGIHRij1N3F8b2LArXs LukwZAouNofE8gh3eO5j8DibaaSK4lUyxepHtPd2R4+M9bDbGyWZ0Pvl7R6mnIwzWdRz OeanZIfu8mzhoVTbga0cfoCtU8P+rAgLnw9vBM6uuTNlu+S4EaI59NCUjh8dV9+NiEx6 i06g== X-Gm-Message-State: AOUpUlG2mo7rBe7TBwJqbkOFN7yir2eRJo377J6fL8GU+2Sn6DzZrk2I ejKEIbbWyEUPrPj6EwafsU7sIg== X-Google-Smtp-Source: AAOMgpfuGLTANNMVZ3Z1pYSpJsuSv1M5qrr0WWzPTR1mxcjFwC8qfJKpnFi00PfhluSuYFpUiIdSkQ== X-Received: by 2002:a1f:5043:: with SMTP id e64-v6mr11367427vkb.47.1531799571375; Mon, 16 Jul 2018 20:52:51 -0700 (PDT) From: Julio Faracco To: libvir-list@redhat.com Date: Tue, 17 Jul 2018 00:52:40 -0300 Message-Id: <20180717035240.17920-1-jcfaracco@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Tue, 17 Jul 2018 03:52:52 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Tue, 17 Jul 2018 03:52:52 +0000 (UTC) for IP:'209.85.213.47' DOMAIN:'mail-vk0-f47.google.com' HELO:'mail-vk0-f47.google.com' FROM:'jcfaracco@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.3 * (DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, NML_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_PASS, T_DKIM_INVALID) 209.85.213.47 mail-vk0-f47.google.com 209.85.213.47 mail-vk0-f47.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.48 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3] qemu: fix broken autostart symlink after renaming domain. X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 17 Jul 2018 03:54:06 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" If a domain is configured to start on boot, it has a symlink to the domain definition inside the autostart directory. If you rename this domain, the definition is renamed too. The symlink need to be pointed to this renamed file. This commit recreates the symlink after renaming the XML file. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D1594985 Signed-off-by: Julio Faracco --- src/qemu/qemu_driver.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 8fae46370e..6bbea324b9 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -20914,6 +20914,8 @@ qemuDomainRenameCallback(virDomainObjPtr vm, char *old_dom_name =3D NULL; char *new_dom_cfg_file =3D NULL; char *old_dom_cfg_file =3D NULL; + char *new_dom_autostart_link =3D NULL; + char *old_dom_autostart_link =3D NULL; =20 virCheckFlags(0, ret); =20 @@ -20934,6 +20936,22 @@ qemuDomainRenameCallback(virDomainObjPtr vm, vm->def->name))) goto cleanup; =20 + if (vm->autostart) { + if (!(new_dom_autostart_link =3D virDomainConfigFile(cfg->autostar= tDir, + new_dom_name)) || + !(old_dom_autostart_link =3D virDomainConfigFile(cfg->autostar= tDir, + vm->def->name))) + goto cleanup; + + if (virFileIsLink(old_dom_autostart_link) && + unlink(old_dom_autostart_link) < 0) { + virReportSystemError(errno, + _("Failed to delete symlink '%s'"), + old_dom_autostart_link); + goto cleanup; + } + } + event_old =3D virDomainEventLifecycleNewFromObj(vm, VIR_DOMAIN_EVENT_UNDEFINED, VIR_DOMAIN_EVENT_UNDEFINED_REN= AMED); @@ -20946,6 +20964,16 @@ qemuDomainRenameCallback(virDomainObjPtr vm, if (virDomainSaveConfig(cfg->configDir, driver->caps, vm->def) < 0) goto rollback; =20 + + if (vm->autostart) { + if (symlink(new_dom_cfg_file, new_dom_autostart_link) < 0) { + virReportSystemError(errno, + _("Failed to create symlink '%s to '%s'"), + new_dom_autostart_link, new_dom_cfg_file); + goto rollback; + } + } + if (virFileExists(old_dom_cfg_file) && unlink(old_dom_cfg_file) < 0) { virReportSystemError(errno, @@ -20960,6 +20988,8 @@ qemuDomainRenameCallback(virDomainObjPtr vm, ret =3D 0; =20 cleanup: + VIR_FREE(old_dom_autostart_link); + VIR_FREE(new_dom_autostart_link); VIR_FREE(old_dom_cfg_file); VIR_FREE(new_dom_cfg_file); VIR_FREE(old_dom_name); @@ -20979,6 +21009,18 @@ qemuDomainRenameCallback(virDomainObjPtr vm, if (virFileExists(new_dom_cfg_file)) unlink(new_dom_cfg_file); =20 + if (vm->autostart) { + if (virFileExists(new_dom_autostart_link)) + unlink(new_dom_autostart_link); + + if (!virFileExists(old_dom_autostart_link) && + symlink(old_dom_cfg_file, old_dom_autostart_link) < 0) { + virReportSystemError(errno, + _("Failed to create symlink '%s to '%s'"), + old_dom_autostart_link, old_dom_cfg_file); + } + } + goto cleanup; } =20 --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list