From nobody Sat Oct 5 21:16:05 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1718875314166156.70056192857464; Thu, 20 Jun 2024 02:21:54 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id D6E6ECA0; Thu, 20 Jun 2024 05:21:52 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 9C018BC0; Thu, 20 Jun 2024 05:21:26 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 9351DB6D; Thu, 20 Jun 2024 05:21:23 -0400 (EDT) Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 67F44A92 for ; Thu, 20 Jun 2024 05:21:22 -0400 (EDT) Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-1f9b364faddso5584195ad.3 for ; Thu, 20 Jun 2024 02:21:22 -0700 (PDT) Received: from localhost.localdomain ([49.47.192.165]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1f855f5e72asm132373225ad.308.2024.06.20.02.21.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Jun 2024 02:21:20 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718875280; x=1719480080; darn=lists.libvirt.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=vyZO/EYaD2jZMwf57ugwq4zFgEdeoTtD0tY6MK4NnUc=; b=JVqWEdOgCIfBGInXLjr/nR39jA1rdUqyNA/YJxCNxKCEvGab4qTBNDSr8X86cMSOwC yCEym7Sl8sYHoBjfCB6qHUk7ChWhHENF8Vxy308sGCvapwoOzs88KUVXwlefK46cR+rL eeZ1TbbefspWux7+3icVoJuo+GGor0O2suN941g5nksF3ZgUxgBcYiVFptosYsvjf3su HnQ7mv5Krwa/RFxZgW6jnq2BM4MGwuU7gCD2PxZ2ccMl8UDhClAHnntZFp9FQUt7ph4E /86gKH8RlD3Q6t/4TjnPWIV7Goik8jbe5Xu6QNKddi5qGvGnkQiGLYMZ0lGI0cJPUa5X Ed8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718875280; x=1719480080; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=vyZO/EYaD2jZMwf57ugwq4zFgEdeoTtD0tY6MK4NnUc=; b=lwfPZud7VYXJsMbrBFqPWQ7K7dMZ8uXd/Ji6d89FErizVu2CM18MoOdoxIwOUSWIfy pO9K3ycaNfE8UbyCbrR2+EiMDl+tz2LoZhPE0nrgqMJOTYBuGp5ku0pz6JuYtoN115zD ddkAwTAAi1KOIIli4PFn+aazE1dlcQFmDiD0kQNUypaZ2OfXjiHmz4ALJWThzfqDjMIc Isx/RO9jZ5aU33JtKUtsqN/Q8J5RCInOXexJWb0PZ0XtfxeC4QHaJCunG59WzP1RDlYf PfNH7kjfG8421qbHc+RT+z2PZyEL+5Aid9OunCbvBgPUzyDrK3Bd3I7VADnhBxluIVc8 qrrQ== X-Gm-Message-State: AOJu0YxyLmvXCqlCoDzG4YcvGy8qsAjcCTUUTBB4cI/bzvZE+WQRb2TG vRUfoVbuFS2bJCuTYyedcxbVOkwOU18P7tCa5HJaCfLN/tq7ekUW+xaYUFJ3sVA= X-Google-Smtp-Source: AGHT+IGGDJN2/X5oqo3Mdvc8SfH9EXiTLixbDxGvJGrx8dMhrtx0ZzofENhKST5thORFbxIHrd5tOA== X-Received: by 2002:a17:903:1248:b0:1f7:2561:cd98 with SMTP id d9443c01a7336-1f9aa47167amr52481905ad.60.1718875280358; Thu, 20 Jun 2024 02:21:20 -0700 (PDT) From: Rayhan Faizel To: devel@lists.libvirt.org Subject: [PATCH] qemu_domain: Check if driver->domainEventState is NULL Date: Thu, 20 Jun 2024 14:51:01 +0530 Message-Id: <20240620092100.4983-1-rayhan.faizel@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 4476AKGV4MWNSTUR4DAJVZSVOQEINVJK X-Message-ID-Hash: 4476AKGV4MWNSTUR4DAJVZSVOQEINVJK X-MailFrom: rayhan.faizel@gmail.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: Rayhan Faizel X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1718875315081100001 Content-Type: text/plain; charset="utf-8" Under the test environment, driver->domainEventState is uninitialized. If a disk gets dropped, it will attempt to queue an event which will cause a segmentation fault. This crash does not occur during normal use. This patch adds a quick check to ensure driver->domainEventState is not NULL along with a testcase exercising the dropping of disks with startupPolicy s= et as 'optional'. Signed-off-by: Rayhan Faizel --- src/qemu/qemu_domain.c | 3 +- ...tuppolicy-optional-drop.x86_64-latest.args | 33 ++++++++++++++++ ...rtuppolicy-optional-drop.x86_64-latest.xml | 38 +++++++++++++++++++ .../disk-startuppolicy-optional-drop.xml | 23 +++++++++++ tests/qemuxmlconftest.c | 2 + 5 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 tests/qemuxmlconfdata/disk-startuppolicy-optional-drop.= x86_64-latest.args create mode 100644 tests/qemuxmlconfdata/disk-startuppolicy-optional-drop.= x86_64-latest.xml create mode 100644 tests/qemuxmlconfdata/disk-startuppolicy-optional-drop.= xml diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 7ba2ea4a5e..109c5bbd52 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -7592,7 +7592,8 @@ qemuDomainCheckRemoveOptionalDisk(virQEMUDriver *driv= er, virDomainDiskDefFree(disk); } =20 - virObjectEventStateQueue(driver->domainEventState, event); + if (driver->domainEventState) + virObjectEventStateQueue(driver->domainEventState, event); } =20 =20 diff --git a/tests/qemuxmlconfdata/disk-startuppolicy-optional-drop.x86_64-= latest.args b/tests/qemuxmlconfdata/disk-startuppolicy-optional-drop.x86_64= -latest.args new file mode 100644 index 0000000000..13ddbc1a5d --- /dev/null +++ b/tests/qemuxmlconfdata/disk-startuppolicy-optional-drop.x86_64-latest.= args @@ -0,0 +1,33 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/var/lib/libvirt/qemu/domain--1-QEMUGuest1 \ +USER=3Dtest \ +LOGNAME=3Dtest \ +XDG_DATA_HOME=3D/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.local/share \ +XDG_CACHE_HOME=3D/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.cache \ +XDG_CONFIG_HOME=3D/var/lib/libvirt/qemu/domain--1-QEMUGuest1/.config \ +/usr/bin/qemu-system-x86_64 \ +-name guest=3DQEMUGuest1,debug-threads=3Don \ +-S \ +-object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/va= r/lib/libvirt/qemu/domain--1-QEMUGuest1/master-key.aes"}' \ +-machine pc,usb=3Doff,dump-guest-core=3Doff,memory-backend=3Dpc.ram,acpi= =3Doff \ +-accel tcg \ +-cpu qemu64 \ +-m size=3D219136k \ +-object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":224395264}'= \ +-overcommit mem-lock=3Doff \ +-smp 1,sockets=3D1,cores=3D1,threads=3D1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=3Dcharmonitor,fd=3D1729,server=3Don,wait=3Doff \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dcontrol \ +-rtc base=3Dutc \ +-no-shutdown \ +-boot strict=3Don \ +-device '{"driver":"piix3-usb-uhci","id":"usb","bus":"pci.0","addr":"0x1.0= x2"}' \ +-device '{"driver":"lsi","id":"scsi0","bus":"pci.0","addr":"0x2"}' \ +-audiodev '{"id":"audio1","driver":"none"}' \ +-sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,resource= control=3Ddeny \ +-msg timestamp=3Don diff --git a/tests/qemuxmlconfdata/disk-startuppolicy-optional-drop.x86_64-= latest.xml b/tests/qemuxmlconfdata/disk-startuppolicy-optional-drop.x86_64-= latest.xml new file mode 100644 index 0000000000..27d0639109 --- /dev/null +++ b/tests/qemuxmlconfdata/disk-startuppolicy-optional-drop.x86_64-latest.= xml @@ -0,0 +1,38 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219100 + 219100 + 1 + + hvm + + + + qemu64 + + + destroy + restart + destroy + + /usr/bin/qemu-system-x86_64 + + + + +
+ + +
+ + + +
+ + + +