From nobody Sun May 5 13:20:27 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 1531974147463740.9072945617847; Wed, 18 Jul 2018 21:22:27 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 53F5E308A96F; Thu, 19 Jul 2018 04:22:24 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DD2FE6012A; Thu, 19 Jul 2018 04:22:22 +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 565754A460; Thu, 19 Jul 2018 04:22:20 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w6J4MHW1019235 for ; Thu, 19 Jul 2018 00:22:17 -0400 Received: by smtp.corp.redhat.com (Postfix) id 27872CB61E; Thu, 19 Jul 2018 04:22:17 +0000 (UTC) Received: from mx1.redhat.com (ext-mx12.extmail.prod.ext.phx2.redhat.com [10.5.110.41]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 20B19CB61C for ; Thu, 19 Jul 2018 04:22:14 +0000 (UTC) Received: from mail-qt0-f194.google.com (mail-qt0-f194.google.com [209.85.216.194]) (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 0D828308A950 for ; Thu, 19 Jul 2018 04:22:03 +0000 (UTC) Received: by mail-qt0-f194.google.com with SMTP id d4-v6so6103263qtn.13 for ; Wed, 18 Jul 2018 21:22:03 -0700 (PDT) Received: from localhost.localdomain ([187.107.181.40]) by smtp.gmail.com with ESMTPSA id r67-v6sm2860544qkd.10.2018.07.18.21.22.00 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Jul 2018 21:22:01 -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=hKLl/iyGRAhtjxChZqN9UNRoSHlhPOXADVAzY9iCiOQ=; b=VUgMKLzqMKLt2X/8YQAhG+MuSwpUjLn5N5w0wEQPhZMLhbg5KccPVk2HWqeoYRqCDD JBvxAUaOJgn6qjVNnuGKP3efVp3Uzh6iEtnSXKqfVPEzL2LZwg7JyYykS6yxsyXtLeNQ dppHVCvjVwlIoR9jsRNdBx1ZmjGSL9ZSiNI98vrhl+X6LUbmp9szC4beo2EDLubKMPXb McuccsH5DeAaBhclq0ua3Q4M1QoZFWAlFLIBv56FRAKnQvrMb5iKEBF6+2eLrrI4ZDrV MavK1i9gx4YUvLn+BIRgnjmH7vH15a7gegKCocKz7j/vb9DCLDHjE3ND3GSVJ3uONrg6 1Wow== 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=hKLl/iyGRAhtjxChZqN9UNRoSHlhPOXADVAzY9iCiOQ=; b=QjjBZupBtGuhIrS3KT4bgmeFCR3D9B5yYxreKh+yy8HGt4uYOoUMgAsZe4LwHgemnM 4Ddf61T1uaRWiNzua8Q8aYV0h+Yw3ycQFDfJppkgPCF9c0voxktBNqeD2DKV0NwXhOn9 4vAF4EzfTdD9VsUxOgDhXMMmqOE3snKCTF980VRd20/h0M61w4cxtNTb85AkXlBsCfZa CZFlkmhISHcfJuZa8pfymhF2jOfuICNSvVc6yasAIUrhWhNzQj9JdQ8LeTMRaZxL2DuM 1WJ1vQjb7eJWqnbO+dOTEzPZkhT6wX4yzjIw6OTNyQUlw3gryCVajTMr5srmvYEIoh0V 3R2Q== X-Gm-Message-State: AOUpUlHWTiu/eTO2Vo5Tit6A/pDZTCCmAT49A2jbnFnY3H1RXMiB65iq /4XC1y0pHVnahM3BqoE7Lv0fNw== X-Google-Smtp-Source: AAOMgpc4NM+faymHJQAddQHZaigzt4Nimate1xyrOlqrC3y8gMY5pqlipwNBhVRD41TxVdipQAOAsQ== X-Received: by 2002:aed:25a2:: with SMTP id x31-v6mr8202775qtc.228.1531974122038; Wed, 18 Jul 2018 21:22:02 -0700 (PDT) From: Julio Faracco To: libvir-list@redhat.com Date: Thu, 19 Jul 2018 01:21:48 -0300 Message-Id: <20180719042148.10476-1-jcfaracco@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Thu, 19 Jul 2018 04:22:03 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Thu, 19 Jul 2018 04:22:03 +0000 (UTC) for IP:'209.85.216.194' DOMAIN:'mail-qt0-f194.google.com' HELO:'mail-qt0-f194.google.com' FROM:'jcfaracco@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.281 * (DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, NML_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_PASS, T_DKIM_INVALID) 209.85.216.194 mail-qt0-f194.google.com 209.85.216.194 mail-qt0-f194.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.41 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.27 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v4] 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Thu, 19 Jul 2018 04:22:25 +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 | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 25170f6f26..09af231dfc 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -20917,6 +20917,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 @@ -20937,6 +20939,14 @@ 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; + } + event_old =3D virDomainEventLifecycleNewFromObj(vm, VIR_DOMAIN_EVENT_UNDEFINED, VIR_DOMAIN_EVENT_UNDEFINED_REN= AMED); @@ -20949,6 +20959,23 @@ qemuDomainRenameCallback(virDomainObjPtr vm, if (virDomainSaveConfig(cfg->configDir, driver->caps, vm->def) < 0) goto rollback; =20 + if (vm->autostart) { + if (virFileIsLink(old_dom_autostart_link) && + unlink(old_dom_autostart_link) < 0) { + virReportSystemError(errno, + _("Failed to delete symlink '%s'"), + old_dom_autostart_link); + goto rollback; + } + + 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, @@ -20963,6 +20990,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); @@ -20982,6 +21011,11 @@ 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); + } + goto cleanup; } =20 --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list