From nobody Thu Apr 25 09:39:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1572537446; cv=none; d=zoho.com; s=zohoarc; b=ZyVlPA+o1fElMJJXjqtyy4l+fK5ikrPIl5UxkEu90goIb7Dz9DzOCkhm8fqjOI1B91f53trNdz+e/IVzO2GSiz9HLQVR0BrbfrLhyEaIFwrqebTLDJ7ZF93xlx4nQyesflKzL0AZMiz3TiZRvt/J7cFqfyrQh9xAa8P36pAX0ws= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1572537446; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=jI8BIuabWTuRg01qaaxsFWLVziW5Z37agMu/g/7eDjY=; b=GFqGCkTfjM5czuSe2GgXEbH/1ufGKTqmmCmZKS4sdUuZDBst8vc+6gjdJVMvkFs8bbJwqqx7PAESuPwjEa4ojsGZNju3/xAunS0yS8+toK/xEVJVyu3j8XVbCW8LFtZ3NbILJVN7I87PH8ffEkqasl5K2QRCj/ePF+hdJ9NsRDM= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1572537446652433.8764181368774; Thu, 31 Oct 2019 08:57:26 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-169-R-wZLMM4N_Gku95I_1hpvA-1; Thu, 31 Oct 2019 11:57:23 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D860B107ACC2; Thu, 31 Oct 2019 15:57:18 +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 A61CA10013D9; Thu, 31 Oct 2019 15:57:18 +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 4E3A54BB65; Thu, 31 Oct 2019 15:57:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9VFvG02023146 for ; Thu, 31 Oct 2019 11:57:17 -0400 Received: by smtp.corp.redhat.com (Postfix) id E9CFA60137; Thu, 31 Oct 2019 15:57:16 +0000 (UTC) Received: from probe.redhat.com (ovpn-126-19.rdu2.redhat.com [10.10.126.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4EDA2600CE; Thu, 31 Oct 2019 15:56:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1572537445; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=jI8BIuabWTuRg01qaaxsFWLVziW5Z37agMu/g/7eDjY=; b=Yc7M2LwwA4hDbj4J5XtMWAPpRWOAhe21lwvQ6UomcNY0YmdWN6ZUR5/gY4H4c5kToNrf7L q3iUc1WFMOWQv7vWZKrn4okTCgYQASo7Gv5yCWHiz0lnxbtfRRl0s3VRB4u+tuiWm5BJj6 NtJ20HvrIsZtIIZ4d36P+sueXetj1E8= From: John Snow To: Peter Maydell , qemu-devel@nongnu.org Date: Thu, 31 Oct 2019 11:56:28 -0400 Message-Id: <20191031155636.18589-2-jsnow@redhat.com> In-Reply-To: <20191031155636.18589-1-jsnow@redhat.com> References: <20191031155636.18589-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: Kevin Wolf , Fam Zheng , Thomas Huth , Peter Krempa , qemu-block@nongnu.org, "Michael S. Tsirkin" , libvir-list@redhat.com, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Laszlo Ersek , "Gonglei \(Arei\)" , Gerd Hoffmann , Stefan Hajnoczi , Laurent Vivier , Paolo Bonzini , Max Reitz , John Snow Subject: [libvirt] [PULL v2 1/9] IDE: deprecate ide-drive 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-MC-Unique: R-wZLMM4N_Gku95I_1hpvA-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" It's an old compatibility shim that just delegates to ide-cd or ide-hd. I'd like to refactor these some day, and getting rid of the super-object will make that easier. Either way, we don't need this. Signed-off-by: John Snow Reviewed-by: Thomas Huth Reviewed-by: Markus Armbruster ACKed-by: Peter Krempa Message-id: 20191009224303.10232-2-jsnow@redhat.com Signed-off-by: John Snow --- qemu-deprecated.texi | 5 +++++ hw/ide/qdev.c | 3 +++ tests/qemu-iotests/051.pc.out | 6 ++++-- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/qemu-deprecated.texi b/qemu-deprecated.texi index f727bd3932..296bfc93a3 100644 --- a/qemu-deprecated.texi +++ b/qemu-deprecated.texi @@ -254,6 +254,11 @@ quite a bit. It will be removed without replacement un= less some users speaks up at the @email{qemu-devel@@nongnu.org} mailing list with information abo= ut their usecases. =20 +@subsection ide-drive (since 4.2) + +The 'ide-drive' device is deprecated. Users should use 'ide-hd' or +'ide-cd' as appropriate to get an IDE hard disk or CD-ROM as needed. + @section System emulator machines =20 @subsection pc-0.12, pc-0.13, pc-0.14 and pc-0.15 (since 4.0) diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c index 6fba6b62b8..3666e59721 100644 --- a/hw/ide/qdev.c +++ b/hw/ide/qdev.c @@ -279,6 +279,9 @@ static void ide_drive_realize(IDEDevice *dev, Error **e= rrp) { DriveInfo *dinfo =3D NULL; =20 + warn_report("'ide-drive' is deprecated, " + "please use 'ide-hd' or 'ide-cd' instead"); + if (dev->conf.blk) { dinfo =3D blk_legacy_dinfo(dev->conf.blk); } diff --git a/tests/qemu-iotests/051.pc.out b/tests/qemu-iotests/051.pc.out index 000557c7c8..34849dd172 100644 --- a/tests/qemu-iotests/051.pc.out +++ b/tests/qemu-iotests/051.pc.out @@ -158,7 +158,8 @@ QEMU X.Y.Z monitor - type 'help' for more information =20 Testing: -drive if=3Dnone,id=3Ddisk -device ide-drive,drive=3Ddisk QEMU X.Y.Z monitor - type 'help' for more information -(qemu) QEMU_PROG: -device ide-drive,drive=3Ddisk: Device needs media, but = drive is empty +(qemu) QEMU_PROG: -device ide-drive,drive=3Ddisk: warning: 'ide-drive' is = deprecated, please use 'ide-hd' or 'ide-cd' instead +QEMU_PROG: -device ide-drive,drive=3Ddisk: Device needs media, but drive i= s empty =20 Testing: -drive if=3Dnone,id=3Ddisk -device ide-hd,drive=3Ddisk QEMU X.Y.Z monitor - type 'help' for more information @@ -228,7 +229,8 @@ QEMU X.Y.Z monitor - type 'help' for more information =20 Testing: -drive file=3DTEST_DIR/t.qcow2,if=3Dnone,id=3Ddisk,readonly=3Don = -device ide-drive,drive=3Ddisk QEMU X.Y.Z monitor - type 'help' for more information -(qemu) QEMU_PROG: -device ide-drive,drive=3Ddisk: Block node is read-only +(qemu) QEMU_PROG: -device ide-drive,drive=3Ddisk: warning: 'ide-drive' is = deprecated, please use 'ide-hd' or 'ide-cd' instead +QEMU_PROG: -device ide-drive,drive=3Ddisk: Block node is read-only =20 Testing: -drive file=3DTEST_DIR/t.qcow2,if=3Dnone,id=3Ddisk,readonly=3Don = -device ide-hd,drive=3Ddisk QEMU X.Y.Z monitor - type 'help' for more information --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu Apr 25 09:39:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1572537466; cv=none; d=zoho.com; s=zohoarc; b=mXLa15a78sbjpL+6v2A//cB8b791BHPcB3nGFcs7onTBLOMPdR9WHdEdWjQ1YzpoBvh7pUmF0Nb+irBrPndPwKQWaajl1wcINDE8uyYnDJ5IvBF/b1PpMuly0hRMvkobHmyZxWrFKpAAIMqCemKGm/NO0cSwJIZeV9g9W6DQ2Ag= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1572537466; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=q6mRRniM8NdXyTwNu4VHOljSENjD3BgZccgArGI49ys=; b=UVYrIHDZnXF999TXkJq8nYg/EE41YYZMJPar+I5TzwXfx+pgEbadTjbMpMfc2QgrPB7FiNm8q4nhcn+kGeSLcqadFw5EoVchC8dURFl3dQFz1yC5ZuabPR9Ef4QJxGyFpWfjbOng3FQHrvLZlGeps6uIHD+R0yk+K08G2WsJjCQ= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1572537466636695.6915866589732; Thu, 31 Oct 2019 08:57:46 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-122-XJ08Qv52PSimAdR0Xbyr6Q-1; Thu, 31 Oct 2019 11:57:43 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id EE3278017E0; Thu, 31 Oct 2019 15:57:38 +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 C78DD60852; Thu, 31 Oct 2019 15:57:38 +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 848F418034EA; Thu, 31 Oct 2019 15:57:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9VFvbWG023165 for ; Thu, 31 Oct 2019 11:57:37 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0497F60132; Thu, 31 Oct 2019 15:57:37 +0000 (UTC) Received: from probe.redhat.com (ovpn-126-19.rdu2.redhat.com [10.10.126.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3BD9B600CD; Thu, 31 Oct 2019 15:57:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1572537465; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=q6mRRniM8NdXyTwNu4VHOljSENjD3BgZccgArGI49ys=; b=ftEq0zEhRoPNrtQF99coSVlVGYkviO1qM9Dy+ngVWIhR9TcJWNxCxuP9KjVJhrhQ65w+ro 5RSsAL/q7fMk0i/gZ+upZLgGXcQ1+BeKoWCDB15yDVQhzgvHJnQXNNpBSLUsKgV7CnWcXb cjafTTdMIbeOUn7LWyRCXZuldzPASA8= From: John Snow To: Peter Maydell , qemu-devel@nongnu.org Date: Thu, 31 Oct 2019 11:56:29 -0400 Message-Id: <20191031155636.18589-3-jsnow@redhat.com> In-Reply-To: <20191031155636.18589-1-jsnow@redhat.com> References: <20191031155636.18589-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: Kevin Wolf , Fam Zheng , Thomas Huth , qemu-block@nongnu.org, "Michael S. Tsirkin" , libvir-list@redhat.com, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Arbel Moshe , Laszlo Ersek , "Gonglei \(Arei\)" , Sam Eiderman , Gerd Hoffmann , Stefan Hajnoczi , Laurent Vivier , Paolo Bonzini , Sam Eiderman , Max Reitz , John Snow , Karl Heubaum Subject: [libvirt] [PULL v2 2/9] block: Refactor macros - fix tabbing 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: , 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-MC-Unique: XJ08Qv52PSimAdR0Xbyr6Q-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) From: Sam Eiderman Fixing tabbing in block related macros. Signed-off-by: Sam Eiderman Signed-off-by: Sam Eiderman Reviewed-by: Karl Heubaum Reviewed-by: Arbel Moshe Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: John Snow --- include/hw/block/block.h | 16 ++++++++-------- hw/ide/qdev.c | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/include/hw/block/block.h b/include/hw/block/block.h index 607539057a..fd55a30bca 100644 --- a/include/hw/block/block.h +++ b/include/hw/block/block.h @@ -50,21 +50,21 @@ static inline unsigned int get_physical_block_exp(Block= Conf *conf) _conf.logical_block_size), \ DEFINE_PROP_BLOCKSIZE("physical_block_size", _state, \ _conf.physical_block_size), \ - DEFINE_PROP_UINT16("min_io_size", _state, _conf.min_io_size, 0), \ + DEFINE_PROP_UINT16("min_io_size", _state, _conf.min_io_size, 0), \ DEFINE_PROP_UINT32("opt_io_size", _state, _conf.opt_io_size, 0), \ - DEFINE_PROP_UINT32("discard_granularity", _state, \ - _conf.discard_granularity, -1), \ - DEFINE_PROP_ON_OFF_AUTO("write-cache", _state, _conf.wce, \ - ON_OFF_AUTO_AUTO), \ + DEFINE_PROP_UINT32("discard_granularity", _state, \ + _conf.discard_granularity, -1), \ + DEFINE_PROP_ON_OFF_AUTO("write-cache", _state, _conf.wce, \ + ON_OFF_AUTO_AUTO), \ DEFINE_PROP_BOOL("share-rw", _state, _conf.share_rw, false) =20 #define DEFINE_BLOCK_PROPERTIES(_state, _conf) \ DEFINE_PROP_DRIVE("drive", _state, _conf.blk), \ DEFINE_BLOCK_PROPERTIES_BASE(_state, _conf) =20 -#define DEFINE_BLOCK_CHS_PROPERTIES(_state, _conf) \ - DEFINE_PROP_UINT32("cyls", _state, _conf.cyls, 0), \ - DEFINE_PROP_UINT32("heads", _state, _conf.heads, 0), \ +#define DEFINE_BLOCK_CHS_PROPERTIES(_state, _conf) \ + DEFINE_PROP_UINT32("cyls", _state, _conf.cyls, 0), \ + DEFINE_PROP_UINT32("heads", _state, _conf.heads, 0), \ DEFINE_PROP_UINT32("secs", _state, _conf.secs, 0) =20 #define DEFINE_BLOCK_ERROR_PROPERTIES(_state, _conf) \ diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c index 3666e59721..85cca6ec38 100644 --- a/hw/ide/qdev.c +++ b/hw/ide/qdev.c @@ -293,7 +293,7 @@ static void ide_drive_realize(IDEDevice *dev, Error **e= rrp) DEFINE_BLOCK_PROPERTIES(IDEDrive, dev.conf), \ DEFINE_BLOCK_ERROR_PROPERTIES(IDEDrive, dev.conf), \ DEFINE_PROP_STRING("ver", IDEDrive, dev.version), \ - DEFINE_PROP_UINT64("wwn", IDEDrive, dev.wwn, 0), \ + DEFINE_PROP_UINT64("wwn", IDEDrive, dev.wwn, 0), \ DEFINE_PROP_STRING("serial", IDEDrive, dev.serial),\ DEFINE_PROP_STRING("model", IDEDrive, dev.model) =20 --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu Apr 25 09:39:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1572537494; cv=none; d=zoho.com; s=zohoarc; b=fFBz8YYAFDQbhgUmzl8c+WiWbgWyLarkp2J0fPGt9eC8ksn/5P2xSGKbPYhnidO2WuZWtmY4VsbN/KiJPQQZnAPm7CMFnVSHWooqF+pKzKxI1r0rfEbLbmkmhgyXrtAZ0SDMOIeSi63xTPMw61R2fsKbKjVbKV/ZrX/BsjM+Q6Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1572537494; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=es7v8mKQcJQK8JuXJYKEEHBy9iu9a0L/RYhyoHjU8bg=; b=S7kuQr4I5li36qzkKce9pArKzKlTtSgeFK0Yfm8JrBsU7vji1LmyOyrfDNGIcxKXbW2M/mgbtweMKxEQxItikuknIzlmF/Qw6WMcLBbV5EZ/7RUTv6gwG3jLo039R49paMUkaDq9grnjAeWkcYTJoIFy0rFzaeRS7wKviC6Grqw= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1572537494501920.3116117934507; Thu, 31 Oct 2019 08:58:14 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-42-q4e6i4ShMymFZbVgu31-kA-1; Thu, 31 Oct 2019 11:58:11 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 21E5C1005500; Thu, 31 Oct 2019 15:58:06 +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 EA08E5D6D6; Thu, 31 Oct 2019 15:58:05 +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 9B8D94BB78; Thu, 31 Oct 2019 15:58:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9VFw45Z023229 for ; Thu, 31 Oct 2019 11:58:04 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4B29260142; Thu, 31 Oct 2019 15:58:04 +0000 (UTC) Received: from probe.redhat.com (ovpn-126-19.rdu2.redhat.com [10.10.126.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4B610600CD; Thu, 31 Oct 2019 15:57:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1572537493; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=es7v8mKQcJQK8JuXJYKEEHBy9iu9a0L/RYhyoHjU8bg=; b=ETJnVhz7VSoAuWPG6xtIykegqJf51q7IRSRNJXOrP5HtelZ6vE5ISNP5oyeU5D9GZ2oAXf yvE9sSWupkrMUmqaOiPi//cDnokF6/wMroZw6qA8ttB58uZTlxYpytfnF+16ZuxHe6hhz7 hZRM0NTHUlEjZFR8f1gLIGyRi0dfuKI= From: John Snow To: Peter Maydell , qemu-devel@nongnu.org Date: Thu, 31 Oct 2019 11:56:30 -0400 Message-Id: <20191031155636.18589-4-jsnow@redhat.com> In-Reply-To: <20191031155636.18589-1-jsnow@redhat.com> References: <20191031155636.18589-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: Kevin Wolf , Fam Zheng , Thomas Huth , qemu-block@nongnu.org, "Michael S. Tsirkin" , libvir-list@redhat.com, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Arbel Moshe , Laszlo Ersek , "Gonglei \(Arei\)" , Sam Eiderman , Gerd Hoffmann , Stefan Hajnoczi , Laurent Vivier , Paolo Bonzini , Sam Eiderman , Max Reitz , John Snow , Karl Heubaum Subject: [libvirt] [PULL v2 3/9] block: Support providing LCHS from user 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-MC-Unique: q4e6i4ShMymFZbVgu31-kA-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) From: Sam Eiderman Add logical geometry variables to BlockConf. A user can now supply "lcyls", "lheads" & "lsecs" for any HD device that supports CHS ("cyls", "heads", "secs"). These devices include: * ide-hd * scsi-hd * virtio-blk-pci In future commits we will use the provided LCHS and pass it to the BIOS through fw_cfg to be supplied using INT13 routines. Reviewed-by: Karl Heubaum Reviewed-by: Arbel Moshe Signed-off-by: Sam Eiderman Signed-off-by: Sam Eiderman Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: John Snow --- include/hw/block/block.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/include/hw/block/block.h b/include/hw/block/block.h index fd55a30bca..d7246f3862 100644 --- a/include/hw/block/block.h +++ b/include/hw/block/block.h @@ -26,6 +26,7 @@ typedef struct BlockConf { uint32_t discard_granularity; /* geometry, not all devices use this */ uint32_t cyls, heads, secs; + uint32_t lcyls, lheads, lsecs; OnOffAuto wce; bool share_rw; BlockdevOnError rerror; @@ -65,7 +66,10 @@ static inline unsigned int get_physical_block_exp(BlockC= onf *conf) #define DEFINE_BLOCK_CHS_PROPERTIES(_state, _conf) \ DEFINE_PROP_UINT32("cyls", _state, _conf.cyls, 0), \ DEFINE_PROP_UINT32("heads", _state, _conf.heads, 0), \ - DEFINE_PROP_UINT32("secs", _state, _conf.secs, 0) + DEFINE_PROP_UINT32("secs", _state, _conf.secs, 0), \ + DEFINE_PROP_UINT32("lcyls", _state, _conf.lcyls, 0), \ + DEFINE_PROP_UINT32("lheads", _state, _conf.lheads, 0), \ + DEFINE_PROP_UINT32("lsecs", _state, _conf.lsecs, 0) =20 #define DEFINE_BLOCK_ERROR_PROPERTIES(_state, _conf) \ DEFINE_PROP_BLOCKDEV_ON_ERROR("rerror", _state, _conf.rerror, \ --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu Apr 25 09:39:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1572537524; cv=none; d=zoho.com; s=zohoarc; b=O/8Z4rCuIkuxsWQafJFdf8NwYiAU43tOSpx9mPY0tolN4oX4W6VqCbQf6BwaW/K9U7NlJI+sgQz5E0F/6cVfbOzPBl9DtMxtNVu1POpq8xmCBFbqGb8kK6QXtMY3ICKu8apEK/qRRo53zuyUfBN1emf4896KyZ1YwhI8HtkdgKk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1572537524; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ibG8Vaj/xc1n3kE9adCGVdKIAMVWif0tEmj6yMI20Zc=; b=WkENrBWido/2MmWqFfteRNQhPvns/6asEisnxmbceghuhWNka6nQREgZ10/T1cHF83ZvwD2iDEjUXZIjuXkAQxJlhPddCgKkkIM/V786maUvMsvmYwkYEwq/t+Ir58Y3ZAiiB/VrO2JwON65+WultiJSW2Id6IKaeaH00lcrXGI= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1572537524829327.2943004420206; Thu, 31 Oct 2019 08:58:44 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-98-R5x6MkT8O6yjnFvbNJPqgQ-1; Thu, 31 Oct 2019 11:58:41 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DCF0B1800D56; Thu, 31 Oct 2019 15:58:36 +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 B2EEC5D6D8; Thu, 31 Oct 2019 15:58:36 +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 6F55418034EA; Thu, 31 Oct 2019 15:58:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9VFwYSK023308 for ; Thu, 31 Oct 2019 11:58:34 -0400 Received: by smtp.corp.redhat.com (Postfix) id C9347600D1; Thu, 31 Oct 2019 15:58:34 +0000 (UTC) Received: from probe.redhat.com (ovpn-126-19.rdu2.redhat.com [10.10.126.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id 924B3600CD; Thu, 31 Oct 2019 15:58:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1572537523; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=ibG8Vaj/xc1n3kE9adCGVdKIAMVWif0tEmj6yMI20Zc=; b=jBgGXVV+xFosAYtxFtM58dkGwcewKck6DtgF/pdhTGMbaWiQ7sPsJcQVwIUPyc1OtaF92C CtSKJ5O2vCAaDVbNjFPit2te4zTFm9JHoDmQDZuKpRc4FU1clJqfbbEJMLU8OwKx2vBmxm WBcfxT5zlwUCRMgtRg3s1a6Td1fct+Q= From: John Snow To: Peter Maydell , qemu-devel@nongnu.org Date: Thu, 31 Oct 2019 11:56:31 -0400 Message-Id: <20191031155636.18589-5-jsnow@redhat.com> In-Reply-To: <20191031155636.18589-1-jsnow@redhat.com> References: <20191031155636.18589-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: Kevin Wolf , Fam Zheng , Thomas Huth , qemu-block@nongnu.org, "Michael S. Tsirkin" , libvir-list@redhat.com, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Arbel Moshe , Laszlo Ersek , "Gonglei \(Arei\)" , Sam Eiderman , Gerd Hoffmann , Stefan Hajnoczi , Laurent Vivier , Paolo Bonzini , Sam Eiderman , Max Reitz , John Snow , Karl Heubaum Subject: [libvirt] [PULL v2 4/9] bootdevice: Add interface to gather LCHS 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-MC-Unique: R5x6MkT8O6yjnFvbNJPqgQ-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) From: Sam Eiderman Add an interface to provide direct logical CHS values for boot devices. We will use this interface in the next commits. Reviewed-by: Karl Heubaum Reviewed-by: Arbel Moshe Signed-off-by: Sam Eiderman Signed-off-by: Sam Eiderman Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: John Snow --- include/sysemu/sysemu.h | 3 +++ bootdevice.c | 55 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index 44f18eb739..5bc5c79cbc 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -103,6 +103,9 @@ void device_add_bootindex_property(Object *obj, int32_t= *bootindex, DeviceState *dev, Error **errp); void restore_boot_order(void *opaque); void validate_bootdevices(const char *devices, Error **errp); +void add_boot_device_lchs(DeviceState *dev, const char *suffix, + uint32_t lcyls, uint32_t lheads, uint32_t lsecs); +void del_boot_device_lchs(DeviceState *dev, const char *suffix); =20 /* handler to set the boot_device order for a specific type of MachineClas= s */ typedef void QEMUBootSetHandler(void *opaque, const char *boot_order, diff --git a/bootdevice.c b/bootdevice.c index 1d225202f9..bc5e1c2de4 100644 --- a/bootdevice.c +++ b/bootdevice.c @@ -343,3 +343,58 @@ void device_add_bootindex_property(Object *obj, int32_= t *bootindex, /* initialize devices' bootindex property to -1 */ object_property_set_int(obj, -1, name, NULL); } + +typedef struct FWLCHSEntry FWLCHSEntry; + +struct FWLCHSEntry { + QTAILQ_ENTRY(FWLCHSEntry) link; + DeviceState *dev; + char *suffix; + uint32_t lcyls; + uint32_t lheads; + uint32_t lsecs; +}; + +static QTAILQ_HEAD(, FWLCHSEntry) fw_lchs =3D + QTAILQ_HEAD_INITIALIZER(fw_lchs); + +void add_boot_device_lchs(DeviceState *dev, const char *suffix, + uint32_t lcyls, uint32_t lheads, uint32_t lsecs) +{ + FWLCHSEntry *node; + + if (!lcyls && !lheads && !lsecs) { + return; + } + + assert(dev !=3D NULL || suffix !=3D NULL); + + node =3D g_malloc0(sizeof(FWLCHSEntry)); + node->suffix =3D g_strdup(suffix); + node->dev =3D dev; + node->lcyls =3D lcyls; + node->lheads =3D lheads; + node->lsecs =3D lsecs; + + QTAILQ_INSERT_TAIL(&fw_lchs, node, link); +} + +void del_boot_device_lchs(DeviceState *dev, const char *suffix) +{ + FWLCHSEntry *i; + + if (dev =3D=3D NULL) { + return; + } + + QTAILQ_FOREACH(i, &fw_lchs, link) { + if ((!suffix || !g_strcmp0(i->suffix, suffix)) && + i->dev =3D=3D dev) { + QTAILQ_REMOVE(&fw_lchs, i, link); + g_free(i->suffix); + g_free(i); + + break; + } + } +} --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu Apr 25 09:39:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1572537547; cv=none; d=zoho.com; s=zohoarc; b=FBrCu7vXHI1DoFIQCSTfUcVmZMUdDiHYzQFq95EzRMEEQPDWTs2Zif15fRBn9n+gnSxvAS8dWcbzrpD/qC4UDnZIxKG6eyReRuKBaoQP3PE2xoMIfp72aiojVZXl+VpXEw8clem4bCJqItYk/gAaCgfBLa5ioMtEg1Qx8pJgMC8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1572537547; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=UTESl6nYUsalORiIipovB3ovyUrKIuS3uRhCc7pprnE=; b=OoNp0JXdCtASv6JKAulr4HDMqTC5JaTfLVYxETxLOlXTvV2xR1ckMxxCRcvD5T+hLod9Zb11UuRf5nwEsFnTRGhnSHzWWWLAFhE4qRfwAdtjyM+hGwVE/zm4hEg7JWpFGXAPGdTb+RYGei6vbP0atSte5Xq5upcHlUYpVuvXWVA= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1572537547802119.148779304242; Thu, 31 Oct 2019 08:59:07 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-271-Zi0QnEe2OP6dG4iwxOhIoA-1; Thu, 31 Oct 2019 11:59:03 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E34D01005500; Thu, 31 Oct 2019 15:58:58 +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 C0FE45DA7C; Thu, 31 Oct 2019 15:58:58 +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 873164A460; Thu, 31 Oct 2019 15:58:58 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9VFwulX023351 for ; Thu, 31 Oct 2019 11:58:56 -0400 Received: by smtp.corp.redhat.com (Postfix) id DAE37600D1; Thu, 31 Oct 2019 15:58:56 +0000 (UTC) Received: from probe.redhat.com (ovpn-126-19.rdu2.redhat.com [10.10.126.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1C655600CD; Thu, 31 Oct 2019 15:58:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1572537545; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=UTESl6nYUsalORiIipovB3ovyUrKIuS3uRhCc7pprnE=; b=FOYmwDmxhI5eg8lk5Yv9gAXRPJgvR1Og2zFSKTC348E5sdOoPNzNWZjNuhXkhFkWAHwFMW 9+0YEAnQy0sgTa1lb51MaMjKpbPF0/M2XRhCrVqgaLOE94nQiGbM6fV2+PzMOxGZvmEmec F9jgLEjDprTN23lDPdKsg2gFH9Fuqsg= From: John Snow To: Peter Maydell , qemu-devel@nongnu.org Date: Thu, 31 Oct 2019 11:56:32 -0400 Message-Id: <20191031155636.18589-6-jsnow@redhat.com> In-Reply-To: <20191031155636.18589-1-jsnow@redhat.com> References: <20191031155636.18589-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: Kevin Wolf , Fam Zheng , Thomas Huth , qemu-block@nongnu.org, "Michael S. Tsirkin" , libvir-list@redhat.com, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Arbel Moshe , Laszlo Ersek , "Gonglei \(Arei\)" , Sam Eiderman , Gerd Hoffmann , Stefan Hajnoczi , Laurent Vivier , Paolo Bonzini , Sam Eiderman , Max Reitz , John Snow , Karl Heubaum Subject: [libvirt] [PULL v2 5/9] scsi: Propagate unrealize() callback to scsi-hd 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: Zi0QnEe2OP6dG4iwxOhIoA-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) From: Sam Eiderman We will need to add LCHS removal logic to scsi-hd's unrealize() in the next commit. Reviewed-by: Karl Heubaum Reviewed-by: Arbel Moshe Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Sam Eiderman Signed-off-by: Sam Eiderman Tested-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: John Snow --- include/hw/scsi/scsi.h | 1 + hw/scsi/scsi-bus.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/include/hw/scsi/scsi.h b/include/hw/scsi/scsi.h index d77a92361b..332ef602f4 100644 --- a/include/hw/scsi/scsi.h +++ b/include/hw/scsi/scsi.h @@ -59,6 +59,7 @@ struct SCSIRequest { typedef struct SCSIDeviceClass { DeviceClass parent_class; void (*realize)(SCSIDevice *dev, Error **errp); + void (*unrealize)(SCSIDevice *dev, Error **errp); int (*parse_cdb)(SCSIDevice *dev, SCSICommand *cmd, uint8_t *buf, void *hba_private); SCSIRequest *(*alloc_req)(SCSIDevice *s, uint32_t tag, uint32_t lun, diff --git a/hw/scsi/scsi-bus.c b/hw/scsi/scsi-bus.c index bccb7cc4c6..359d50d6d0 100644 --- a/hw/scsi/scsi-bus.c +++ b/hw/scsi/scsi-bus.c @@ -59,6 +59,14 @@ static void scsi_device_realize(SCSIDevice *s, Error **e= rrp) } } =20 +static void scsi_device_unrealize(SCSIDevice *s, Error **errp) +{ + SCSIDeviceClass *sc =3D SCSI_DEVICE_GET_CLASS(s); + if (sc->unrealize) { + sc->unrealize(s, errp); + } +} + int scsi_bus_parse_cdb(SCSIDevice *dev, SCSICommand *cmd, uint8_t *buf, void *hba_private) { @@ -217,12 +225,20 @@ static void scsi_qdev_realize(DeviceState *qdev, Erro= r **errp) static void scsi_qdev_unrealize(DeviceState *qdev, Error **errp) { SCSIDevice *dev =3D SCSI_DEVICE(qdev); + Error *local_err =3D NULL; =20 if (dev->vmsentry) { qemu_del_vm_change_state_handler(dev->vmsentry); } =20 scsi_device_purge_requests(dev, SENSE_CODE(NO_SENSE)); + + scsi_device_unrealize(dev, &local_err); + if (local_err) { + error_propagate(errp, local_err); + return; + } + blockdev_mark_auto_del(dev->conf.blk); } =20 --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu Apr 25 09:39:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1572537567; cv=none; d=zoho.com; s=zohoarc; b=Tn3MqJuVLXnUIJjNC0h1RA71z9AnoYB3NzsWrlb1pihoHDC5PYoLAzTXf55GedohVMRR1nyVmGNvmNDiVjdbvaTRpvD/6PROvvHFA68HOTnDZ99kLZ7QOJ1L4T1XtCqpWHEE0I9fKqsmGCoCrmvl4+5P79bVImbtjo4b8kcUWe8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1572537567; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=93aJA6+mxexUr3Gi+DIRJUv58kiQ0wWnywItdp7Lnbo=; b=a+WuTHC9KfgzTgyECCvkufnyKAULT3zXkf/X5oRKL4QNh5ItSG0Hk324y0M/Pb/oL9Y7pbGZa05PJxxxL07HbBgdq7sctF0UyW3LkPDSnoDi+6x+OOxBuSv+dTIYKhWwHFXahjXm4m7tPY8KoN261I5Rx5JnzFn8NMO+4Qi/kB8= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1572537567569116.18990975175655; Thu, 31 Oct 2019 08:59:27 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-243-qTO4ijhzPhuTpq2hBhIccw-1; Thu, 31 Oct 2019 11:59:24 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 273641005500; Thu, 31 Oct 2019 15:59:20 +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 EE6F35D6D6; Thu, 31 Oct 2019 15:59:19 +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 A187618034EB; Thu, 31 Oct 2019 15:59:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9VFxITX023397 for ; Thu, 31 Oct 2019 11:59:18 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8C2AB60136; Thu, 31 Oct 2019 15:59:18 +0000 (UTC) Received: from probe.redhat.com (ovpn-126-19.rdu2.redhat.com [10.10.126.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2CB24600CD; Thu, 31 Oct 2019 15:58:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1572537566; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=93aJA6+mxexUr3Gi+DIRJUv58kiQ0wWnywItdp7Lnbo=; b=Z08fP/zAi0RVhsabxA7kCuLPbyYiMs5VxFX3zgxXL7I8rgmGzj5pZ+xy+0qS0oq1DSZZVA 4iCF3N1k1E9085w1qbsZzoAWgSvZ/aW/RM6NmgQIF6BzNZ7pcVx9BRO4dwwXy7oJnSRfNI 2KcnA/LafSqv4i/dcCQeN/+BvfzUIaA= From: John Snow To: Peter Maydell , qemu-devel@nongnu.org Date: Thu, 31 Oct 2019 11:56:33 -0400 Message-Id: <20191031155636.18589-7-jsnow@redhat.com> In-Reply-To: <20191031155636.18589-1-jsnow@redhat.com> References: <20191031155636.18589-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: Kevin Wolf , Fam Zheng , Thomas Huth , qemu-block@nongnu.org, "Michael S. Tsirkin" , libvir-list@redhat.com, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Arbel Moshe , Laszlo Ersek , "Gonglei \(Arei\)" , Sam Eiderman , Gerd Hoffmann , Stefan Hajnoczi , Laurent Vivier , Paolo Bonzini , Sam Eiderman , Max Reitz , John Snow , Karl Heubaum Subject: [libvirt] [PULL v2 6/9] bootdevice: Gather LCHS from all relevant devices 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-MC-Unique: qTO4ijhzPhuTpq2hBhIccw-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) From: Sam Eiderman Relevant devices are: * ide-hd (and ide-cd, ide-drive) * scsi-hd (and scsi-cd, scsi-disk, scsi-block) * virtio-blk-pci We do not call del_boot_device_lchs() for ide-* since we don't need to - IDE block devices do not support unplugging. Reviewed-by: Karl Heubaum Reviewed-by: Arbel Moshe Signed-off-by: Sam Eiderman Signed-off-by: Sam Eiderman Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: John Snow --- hw/block/virtio-blk.c | 6 ++++++ hw/ide/qdev.c | 5 +++++ hw/scsi/scsi-disk.c | 12 ++++++++++++ 3 files changed, 23 insertions(+) diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index 9fa2eaf890..4c357d2928 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -1200,6 +1200,11 @@ static void virtio_blk_device_realize(DeviceState *d= ev, Error **errp) blk_set_guest_block_size(s->blk, s->conf.conf.logical_block_size); =20 blk_iostatus_enable(s->blk); + + add_boot_device_lchs(dev, "/disk@0,0", + conf->conf.lcyls, + conf->conf.lheads, + conf->conf.lsecs); } =20 static void virtio_blk_device_unrealize(DeviceState *dev, Error **errp) @@ -1210,6 +1215,7 @@ static void virtio_blk_device_unrealize(DeviceState *= dev, Error **errp) unsigned i; =20 blk_drain(s->blk); + del_boot_device_lchs(dev, "/disk@0,0"); virtio_blk_data_plane_destroy(s->dataplane); s->dataplane =3D NULL; for (i =3D 0; i < conf->num_queues; i++) { diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c index 85cca6ec38..374a791a45 100644 --- a/hw/ide/qdev.c +++ b/hw/ide/qdev.c @@ -220,6 +220,11 @@ static void ide_dev_initfn(IDEDevice *dev, IDEDriveKin= d kind, Error **errp) =20 add_boot_device_path(dev->conf.bootindex, &dev->qdev, dev->unit ? "/disk@1" : "/disk@0"); + + add_boot_device_lchs(&dev->qdev, dev->unit ? "/disk@1" : "/disk@0", + dev->conf.lcyls, + dev->conf.lheads, + dev->conf.lsecs); } =20 static void ide_dev_get_bootindex(Object *obj, Visitor *v, const char *nam= e, diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c index 68b1675fd9..07fb5ebdf1 100644 --- a/hw/scsi/scsi-disk.c +++ b/hw/scsi/scsi-disk.c @@ -35,6 +35,7 @@ #include "hw/block/block.h" #include "hw/qdev-properties.h" #include "sysemu/dma.h" +#include "sysemu/sysemu.h" #include "qemu/cutils.h" #include "trace.h" =20 @@ -2414,6 +2415,16 @@ static void scsi_realize(SCSIDevice *dev, Error **er= rp) blk_set_guest_block_size(s->qdev.conf.blk, s->qdev.blocksize); =20 blk_iostatus_enable(s->qdev.conf.blk); + + add_boot_device_lchs(&dev->qdev, NULL, + dev->conf.lcyls, + dev->conf.lheads, + dev->conf.lsecs); +} + +static void scsi_unrealize(SCSIDevice *dev, Error **errp) +{ + del_boot_device_lchs(&dev->qdev, NULL); } =20 static void scsi_hd_realize(SCSIDevice *dev, Error **errp) @@ -3018,6 +3029,7 @@ static void scsi_hd_class_initfn(ObjectClass *klass, = void *data) SCSIDeviceClass *sc =3D SCSI_DEVICE_CLASS(klass); =20 sc->realize =3D scsi_hd_realize; + sc->unrealize =3D scsi_unrealize; sc->alloc_req =3D scsi_new_request; sc->unit_attention_reported =3D scsi_disk_unit_attention_reported; dc->desc =3D "virtual SCSI disk"; --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu Apr 25 09:39:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1572537589; cv=none; d=zoho.com; s=zohoarc; b=M3D8vGD2dze35TtbH4uLOQ4qgzPsagZNuNL55GIIOjP9rB7ih+iG2mPX1gIYWKoOvNY5yuPva0ylDWFjKEGGQ919W9E3AbWkUU+CYM2CU98qRRfzu3pap7b8zeEK8IoEcnNLLQvtxwxWXxmpeP5c6pZjviGBDFiXH/MnCBh5yPk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1572537589; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=EJDP1zzShYEvPU/84+2fHJwA4AfF5OvZwkYGbRwK658=; b=YTofUf8RcTnFCDkL7W6H1j7H3XRyGDUFEx06pLQaRHebLbIk4rbFQWa4gv0Ykd0nM5f3zpGGb5uOBf3fWyutNpyCEIsRh3EdVc+zcEUdC438HRBolGZNAGfFIJ7KZFsSdnGFZtgrSY4bjBNsyfmQ3ehI8lFZxb+OLDg9BwXPaWw= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 15725375899341005.3027442066547; Thu, 31 Oct 2019 08:59:49 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-34-3QIJ8lCGOJa9fTkx7hvCEA-1; Thu, 31 Oct 2019 11:59:46 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8DB441005500; Thu, 31 Oct 2019 15:59:41 +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 69E7D5D6D8; Thu, 31 Oct 2019 15:59:41 +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 293134BB65; Thu, 31 Oct 2019 15:59:41 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9VFxdD9023430 for ; Thu, 31 Oct 2019 11:59:39 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2C73560138; Thu, 31 Oct 2019 15:59:39 +0000 (UTC) Received: from probe.redhat.com (ovpn-126-19.rdu2.redhat.com [10.10.126.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id D299E600CD; Thu, 31 Oct 2019 15:59:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1572537588; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=EJDP1zzShYEvPU/84+2fHJwA4AfF5OvZwkYGbRwK658=; b=hxW+nK11IMjLlYsDVtVhsMDEs0GrgnxILe2BC7BCnVFhwxSiZF1u9M6jfAdNpBqCbybzLu 4XZYXYWzSy3nF8VT2k5THbboB9K3nmlA/gcX4SyYcnKbdz1aG/5uWMgED6pcYr+S5r6anv YeJzloWsUgjG1JAAUVLPVHQ754pf+YM= From: John Snow To: Peter Maydell , qemu-devel@nongnu.org Date: Thu, 31 Oct 2019 11:56:34 -0400 Message-Id: <20191031155636.18589-8-jsnow@redhat.com> In-Reply-To: <20191031155636.18589-1-jsnow@redhat.com> References: <20191031155636.18589-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: Kevin Wolf , Fam Zheng , Thomas Huth , qemu-block@nongnu.org, "Michael S. Tsirkin" , libvir-list@redhat.com, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Arbel Moshe , Laszlo Ersek , "Gonglei \(Arei\)" , Sam Eiderman , Gerd Hoffmann , Stefan Hajnoczi , Laurent Vivier , Paolo Bonzini , Sam Eiderman , Max Reitz , John Snow , Karl Heubaum Subject: [libvirt] [PULL v2 7/9] bootdevice: Refactor get_boot_devices_list 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-MC-Unique: 3QIJ8lCGOJa9fTkx7hvCEA-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) From: Sam Eiderman Move device name construction to a separate function. We will reuse this function in the following commit to pass logical CHS parameters through fw_cfg much like we currently pass bootindex. Reviewed-by: Karl Heubaum Reviewed-by: Arbel Moshe Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Sam Eiderman Signed-off-by: Sam Eiderman Tested-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: John Snow --- bootdevice.c | 61 +++++++++++++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 27 deletions(-) diff --git a/bootdevice.c b/bootdevice.c index bc5e1c2de4..2cf6b37c57 100644 --- a/bootdevice.c +++ b/bootdevice.c @@ -202,6 +202,39 @@ DeviceState *get_boot_device(uint32_t position) return res; } =20 +static char *get_boot_device_path(DeviceState *dev, bool ignore_suffixes, + const char *suffix) +{ + char *devpath =3D NULL, *s =3D NULL, *d, *bootpath; + + if (dev) { + devpath =3D qdev_get_fw_dev_path(dev); + assert(devpath); + } + + if (!ignore_suffixes) { + if (dev) { + d =3D qdev_get_own_fw_dev_path_from_handler(dev->parent_bus, d= ev); + if (d) { + assert(!suffix); + s =3D d; + } else { + s =3D g_strdup(suffix); + } + } else { + s =3D g_strdup(suffix); + } + } + + bootpath =3D g_strdup_printf("%s%s", + devpath ? devpath : "", + s ? s : ""); + g_free(devpath); + g_free(s); + + return bootpath; +} + /* * This function returns null terminated string that consist of new line * separated device paths. @@ -218,36 +251,10 @@ char *get_boot_devices_list(size_t *size) bool ignore_suffixes =3D mc->ignore_boot_device_suffixes; =20 QTAILQ_FOREACH(i, &fw_boot_order, link) { - char *devpath =3D NULL, *suffix =3D NULL; char *bootpath; - char *d; size_t len; =20 - if (i->dev) { - devpath =3D qdev_get_fw_dev_path(i->dev); - assert(devpath); - } - - if (!ignore_suffixes) { - if (i->dev) { - d =3D qdev_get_own_fw_dev_path_from_handler(i->dev->parent= _bus, - i->dev); - if (d) { - assert(!i->suffix); - suffix =3D d; - } else { - suffix =3D g_strdup(i->suffix); - } - } else { - suffix =3D g_strdup(i->suffix); - } - } - - bootpath =3D g_strdup_printf("%s%s", - devpath ? devpath : "", - suffix ? suffix : ""); - g_free(devpath); - g_free(suffix); + bootpath =3D get_boot_device_path(i->dev, ignore_suffixes, i->suff= ix); =20 if (total) { list[total-1] =3D '\n'; --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu Apr 25 09:39:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1572537610; cv=none; d=zoho.com; s=zohoarc; b=cIA8tjQibz0MAwz5JdlHYhruLCZhC3qIuHBn+0xodHapHBmY/ms9rPc6Zr1isLHyLSET9QTa1LMnqNmtK6xQ6WqUkZgn+NqqcmQ/WZ5txsDGnb34/KaHW6o0m1FCWXdZyyGZtxdVmGTauh9wAyfsHKM4+vUJbUVwqRrDeepC+DA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1572537610; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ILzsOx35yTFnmN26OftYk/0j1dCnqpTXTGcWEA3AmT4=; b=I2tTcI045dEQ3Fb68Heq1HM3LYh6B89Yo+Uk99+uGTH61WMOa5aaed52FssPB9I/gBfKDQBWO3qdc6FO6UmtALB7kt2POoNdIfLQMLKpkbmp+cY8A9LMKMXTDPfnxvfhauNEG52tJaoJ89ICWINJI48YTZRR88ZgykmFkcDNlDk= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1572537610257561.8245987675008; Thu, 31 Oct 2019 09:00:10 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-45-uv1dPw0ZP2CT7BZxph1adQ-1; Thu, 31 Oct 2019 12:00:06 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 55C5E800EC0; Thu, 31 Oct 2019 16:00:01 +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 2A7321001B32; Thu, 31 Oct 2019 16:00:01 +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 D452718034EA; Thu, 31 Oct 2019 16:00:00 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9VG00bj023463 for ; Thu, 31 Oct 2019 12:00:00 -0400 Received: by smtp.corp.redhat.com (Postfix) id F05146013D; Thu, 31 Oct 2019 15:59:59 +0000 (UTC) Received: from probe.redhat.com (ovpn-126-19.rdu2.redhat.com [10.10.126.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id 71CF1600CD; Thu, 31 Oct 2019 15:59:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1572537609; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=ILzsOx35yTFnmN26OftYk/0j1dCnqpTXTGcWEA3AmT4=; b=VzNjmzbMy0afb8RMW8m8pSMQgiEbOnC8S1tlNBesm5j0n0rTsn6gD6+fhE8zyJF4q042vO 5Hhvho58wFUee0tJc6MrdtDiypQ69ahBzZtcqdkMrXpBJKeZcM1PhpDTIW1+A1x9Dwb24X Ha1iI/dp/AY1EJ3apHtS/WXiVHm8zR0= From: John Snow To: Peter Maydell , qemu-devel@nongnu.org Date: Thu, 31 Oct 2019 11:56:35 -0400 Message-Id: <20191031155636.18589-9-jsnow@redhat.com> In-Reply-To: <20191031155636.18589-1-jsnow@redhat.com> References: <20191031155636.18589-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: Kevin Wolf , Fam Zheng , Thomas Huth , qemu-block@nongnu.org, "Michael S. Tsirkin" , libvir-list@redhat.com, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Arbel Moshe , Laszlo Ersek , "Gonglei \(Arei\)" , Sam Eiderman , Gerd Hoffmann , Stefan Hajnoczi , Laurent Vivier , Paolo Bonzini , Sam Eiderman , Max Reitz , John Snow , Karl Heubaum Subject: [libvirt] [PULL v2 8/9] bootdevice: FW_CFG interface for LCHS values 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-MC-Unique: uv1dPw0ZP2CT7BZxph1adQ-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) From: Sam Eiderman Using fw_cfg, supply logical CHS values directly from QEMU to the BIOS. Non-standard logical geometries break under QEMU. A virtual disk which contains an operating system which depends on logical geometries (consistent values being reported from BIOS INT13 AH=3D08) will most likely break under QEMU/SeaBIOS if it has non-standard logical geometries - for example 56 SPT (sectors per track). No matter what QEMU will report - SeaBIOS, for large enough disks - will use LBA translation, which will report 63 SPT instead. In addition we cannot force SeaBIOS to rely on physical geometries at all. A virtio-blk-pci virtual disk with 255 phyiscal heads cannot report more than 16 physical heads when moved to an IDE controller, since the ATA spec allows a maximum of 16 heads - this is an artifact of virtualization. By supplying the logical geometries directly we are able to support such "exotic" disks. We serialize this information in a similar way to the "bootorder" interface. The new fw_cfg entry is "bios-geometry". Reviewed-by: Karl Heubaum Reviewed-by: Arbel Moshe Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Sam Eiderman Signed-off-by: Sam Eiderman Tested-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: John Snow --- include/sysemu/sysemu.h | 1 + bootdevice.c | 31 +++++++++++++++++++++++++++++++ hw/nvram/fw_cfg.c | 14 +++++++++++--- 3 files changed, 43 insertions(+), 3 deletions(-) diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index 5bc5c79cbc..80c57fdc4e 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -106,6 +106,7 @@ void validate_bootdevices(const char *devices, Error **= errp); void add_boot_device_lchs(DeviceState *dev, const char *suffix, uint32_t lcyls, uint32_t lheads, uint32_t lsecs); void del_boot_device_lchs(DeviceState *dev, const char *suffix); +char *get_boot_devices_lchs_list(size_t *size); =20 /* handler to set the boot_device order for a specific type of MachineClas= s */ typedef void QEMUBootSetHandler(void *opaque, const char *boot_order, diff --git a/bootdevice.c b/bootdevice.c index 2cf6b37c57..03aaffcc8d 100644 --- a/bootdevice.c +++ b/bootdevice.c @@ -405,3 +405,34 @@ void del_boot_device_lchs(DeviceState *dev, const char= *suffix) } } } + +char *get_boot_devices_lchs_list(size_t *size) +{ + FWLCHSEntry *i; + size_t total =3D 0; + char *list =3D NULL; + + QTAILQ_FOREACH(i, &fw_lchs, link) { + char *bootpath; + char *chs_string; + size_t len; + + bootpath =3D get_boot_device_path(i->dev, false, i->suffix); + chs_string =3D g_strdup_printf("%s %" PRIu32 " %" PRIu32 " %" PRIu= 32, + bootpath, i->lcyls, i->lheads, i->lse= cs); + + if (total) { + list[total - 1] =3D '\n'; + } + len =3D strlen(chs_string) + 1; + list =3D g_realloc(list, total + len); + memcpy(&list[total], chs_string, len); + total +=3D len; + g_free(chs_string); + g_free(bootpath); + } + + *size =3D total; + + return list; +} diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c index aef1727250..44a3c19326 100644 --- a/hw/nvram/fw_cfg.c +++ b/hw/nvram/fw_cfg.c @@ -949,13 +949,21 @@ void *fw_cfg_modify_file(FWCfgState *s, const char *f= ilename, =20 static void fw_cfg_machine_reset(void *opaque) { + MachineClass *mc =3D MACHINE_GET_CLASS(qdev_get_machine()); + FWCfgState *s =3D opaque; void *ptr; size_t len; - FWCfgState *s =3D opaque; - char *bootindex =3D get_boot_devices_list(&len); + char *buf; =20 - ptr =3D fw_cfg_modify_file(s, "bootorder", (uint8_t *)bootindex, len); + buf =3D get_boot_devices_list(&len); + ptr =3D fw_cfg_modify_file(s, "bootorder", (uint8_t *)buf, len); g_free(ptr); + + if (!mc->legacy_fw_cfg_order) { + buf =3D get_boot_devices_lchs_list(&len); + ptr =3D fw_cfg_modify_file(s, "bios-geometry", (uint8_t *)buf, len= ); + g_free(ptr); + } } =20 static void fw_cfg_machine_ready(struct Notifier *n, void *data) --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Thu Apr 25 09:39:04 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1572537647; cv=none; d=zoho.com; s=zohoarc; b=OhuRoz+GgGyLU+8lWK1M6Kuom/S2WiPYTVIiAK9AWAQpM4fLBqZeDlWbsbL/zwktqEWqD8CjQCHmDQbTmF6LX5HuIEyIDKbq4l74UDg86WZpHb+nD5Fppv5Z8k/pRnRJR7QLyElRueiGAaYtlLsjYGMFXRnKfdoJ5O/qIA48mR0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1572537647; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=5Mkg380Ps+lSVJARL+VR75k3X1Lqx+Z86oTZ7VAYZ9o=; b=azRqG/JPOeh0Yy4akp5EXkXIMrxaqO9q7S1WNpkCkeedB2bO+AHdTo0rz/wu5V2o2xOWc4fcQSWb0/j6FbY3TshJ1Az7a2imdX1GHai1cfqCvfQaft/A0w4VlIJdVqYkfA4Vy5bWsSw2UTOPc+24MsYYpNDlBMxwONPlxAJ8z+0= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1572537647047952.3704369607055; Thu, 31 Oct 2019 09:00:47 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-18-FEGYxj70NY2xvsvkNa_hUQ-1; Thu, 31 Oct 2019 12:00:43 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 28660107ACC0; Thu, 31 Oct 2019 16:00:38 +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 E62B51001B32; Thu, 31 Oct 2019 16:00:37 +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 904DD18034ED; Thu, 31 Oct 2019 16:00:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9VG0Zka023526 for ; Thu, 31 Oct 2019 12:00:35 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9683060138; Thu, 31 Oct 2019 16:00:35 +0000 (UTC) Received: from probe.redhat.com (ovpn-126-19.rdu2.redhat.com [10.10.126.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id 408E1600CD; Thu, 31 Oct 2019 16:00:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1572537645; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=5Mkg380Ps+lSVJARL+VR75k3X1Lqx+Z86oTZ7VAYZ9o=; b=Cu8uH8Cuys6JltgQh3l43bzRT2zLwXEbpPSycWpGjBQYiONPsT3hN+Hdqh1FsLmgeESCNg R9tmLaYfkHOh5sMrPDCpSAq/fpSgJ7xdjEgAINUTQdjzm/y6BXD726e+loUC0gQWQrAlfC ByzhEKe5oLpiDkUBuFVgtv0MvflRzCs= From: John Snow To: Peter Maydell , qemu-devel@nongnu.org Date: Thu, 31 Oct 2019 11:56:36 -0400 Message-Id: <20191031155636.18589-10-jsnow@redhat.com> In-Reply-To: <20191031155636.18589-1-jsnow@redhat.com> References: <20191031155636.18589-1-jsnow@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: Kevin Wolf , Fam Zheng , Thomas Huth , qemu-block@nongnu.org, "Michael S. Tsirkin" , libvir-list@redhat.com, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Arbel Moshe , Laszlo Ersek , "Gonglei \(Arei\)" , Sam Eiderman , Gerd Hoffmann , Stefan Hajnoczi , Laurent Vivier , Paolo Bonzini , Sam Eiderman , Max Reitz , John Snow , Karl Heubaum Subject: [libvirt] [PULL v2 9/9] hd-geo-test: Add tests for lchs override 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-MC-Unique: FEGYxj70NY2xvsvkNa_hUQ-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Sam Eiderman Add QTest tests to check the logical geometry override option. The tests in hd-geo-test are out of date - they only test IDE and do not test interesting MBRs. Creating qcow2 disks with specific size and MBR layout is currently unused - we only use a default empty MBR. Reviewed-by: Karl Heubaum Reviewed-by: Arbel Moshe Signed-off-by: Sam Eiderman Signed-off-by: Sam Eiderman Signed-off-by: John Snow --- tests/hd-geo-test.c | 551 +++++++++++++++++++++++++++++++++++++++++ tests/Makefile.include | 2 +- 2 files changed, 552 insertions(+), 1 deletion(-) diff --git a/tests/hd-geo-test.c b/tests/hd-geo-test.c index 62eb624726..7e86c5416c 100644 --- a/tests/hd-geo-test.c +++ b/tests/hd-geo-test.c @@ -17,7 +17,12 @@ =20 #include "qemu/osdep.h" #include "qemu-common.h" +#include "qemu/bswap.h" +#include "qapi/qmp/qlist.h" #include "libqtest.h" +#include "libqos/fw_cfg.h" +#include "libqos/libqos.h" +#include "standard-headers/linux/qemu_fw_cfg.h" =20 #define ARGV_SIZE 256 =20 @@ -388,6 +393,537 @@ static void test_ide_drive_cd_0(void) qtest_quit(qts); } =20 +typedef struct { + bool active; + uint32_t head; + uint32_t sector; + uint32_t cyl; + uint32_t end_head; + uint32_t end_sector; + uint32_t end_cyl; + uint32_t start_sect; + uint32_t nr_sects; +} MBRpartitions[4]; + +static MBRpartitions empty_mbr =3D { {false, 0, 0, 0, 0, 0, 0, 0, 0}, + {false, 0, 0, 0, 0, 0, 0, 0, 0}, + {false, 0, 0, 0, 0, 0, 0, 0, 0}, + {false, 0, 0, 0, 0, 0, 0, 0, 0} }; + +static char *create_qcow2_with_mbr(MBRpartitions mbr, uint64_t sectors) +{ + const char *template =3D "/tmp/qtest.XXXXXX"; + char *raw_path =3D strdup(template); + char *qcow2_path =3D strdup(template); + char cmd[100 + 2 * PATH_MAX]; + uint8_t buf[512]; + int i, ret, fd, offset; + uint64_t qcow2_size =3D sectors * 512; + uint8_t status, parttype, head, sector, cyl; + char *qemu_img_path; + char *qemu_img_abs_path; + + offset =3D 0xbe; + + for (i =3D 0; i < 4; i++) { + status =3D mbr[i].active ? 0x80 : 0x00; + g_assert(mbr[i].head < 256); + g_assert(mbr[i].sector < 64); + g_assert(mbr[i].cyl < 1024); + head =3D mbr[i].head; + sector =3D mbr[i].sector + ((mbr[i].cyl & 0x300) >> 2); + cyl =3D mbr[i].cyl & 0xff; + + buf[offset + 0x0] =3D status; + buf[offset + 0x1] =3D head; + buf[offset + 0x2] =3D sector; + buf[offset + 0x3] =3D cyl; + + parttype =3D 0; + g_assert(mbr[i].end_head < 256); + g_assert(mbr[i].end_sector < 64); + g_assert(mbr[i].end_cyl < 1024); + head =3D mbr[i].end_head; + sector =3D mbr[i].end_sector + ((mbr[i].end_cyl & 0x300) >> 2); + cyl =3D mbr[i].end_cyl & 0xff; + + buf[offset + 0x4] =3D parttype; + buf[offset + 0x5] =3D head; + buf[offset + 0x6] =3D sector; + buf[offset + 0x7] =3D cyl; + + (*(uint32_t *)&buf[offset + 0x8]) =3D cpu_to_le32(mbr[i].start_sec= t); + (*(uint32_t *)&buf[offset + 0xc]) =3D cpu_to_le32(mbr[i].nr_sects); + + offset +=3D 0x10; + } + + fd =3D mkstemp(raw_path); + g_assert(fd); + close(fd); + + fd =3D open(raw_path, O_WRONLY); + g_assert(fd >=3D 0); + ret =3D write(fd, buf, sizeof(buf)); + g_assert(ret =3D=3D sizeof(buf)); + close(fd); + + fd =3D mkstemp(qcow2_path); + g_assert(fd); + close(fd); + + qemu_img_path =3D getenv("QTEST_QEMU_IMG"); + g_assert(qemu_img_path); + qemu_img_abs_path =3D realpath(qemu_img_path, NULL); + g_assert(qemu_img_abs_path); + + ret =3D snprintf(cmd, sizeof(cmd), + "%s convert -f raw -O qcow2 %s %s > /dev/null", + qemu_img_abs_path, + raw_path, qcow2_path); + g_assert((0 < ret) && (ret <=3D sizeof(cmd))); + ret =3D system(cmd); + g_assert(ret =3D=3D 0); + + ret =3D snprintf(cmd, sizeof(cmd), + "%s resize %s %" PRIu64 " > /dev/null", + qemu_img_abs_path, + qcow2_path, qcow2_size); + g_assert((0 < ret) && (ret <=3D sizeof(cmd))); + ret =3D system(cmd); + g_assert(ret =3D=3D 0); + + free(qemu_img_abs_path); + + unlink(raw_path); + free(raw_path); + + return qcow2_path; +} + +#define BIOS_GEOMETRY_MAX_SIZE 10000 + +typedef struct { + uint32_t c; + uint32_t h; + uint32_t s; +} CHS; + +typedef struct { + const char *dev_path; + CHS chs; +} CHSResult; + +static void read_bootdevices(QFWCFG *fw_cfg, CHSResult expected[]) +{ + char *buf =3D g_malloc0(BIOS_GEOMETRY_MAX_SIZE); + char *cur; + GList *results =3D NULL, *cur_result; + CHSResult *r; + int i; + int res; + bool found; + + qfw_cfg_get_file(fw_cfg, "bios-geometry", buf, BIOS_GEOMETRY_MAX_SIZE); + + for (cur =3D buf; *cur; cur++) { + if (*cur =3D=3D '\n') { + *cur =3D '\0'; + } + } + cur =3D buf; + + while (strlen(cur)) { + + r =3D g_malloc0(sizeof(*r)); + r->dev_path =3D g_malloc0(strlen(cur) + 1); + res =3D sscanf(cur, "%s %" PRIu32 " %" PRIu32 " %" PRIu32, + (char *)r->dev_path, + &(r->chs.c), &(r->chs.h), &(r->chs.s)); + + g_assert(res =3D=3D 4); + + results =3D g_list_prepend(results, r); + + cur +=3D strlen(cur) + 1; + } + + i =3D 0; + + while (expected[i].dev_path) { + found =3D false; + cur_result =3D results; + while (cur_result) { + r =3D cur_result->data; + if (!strcmp(r->dev_path, expected[i].dev_path) && + !memcmp(&(r->chs), &(expected[i].chs), sizeof(r->chs))) { + found =3D true; + break; + } + cur_result =3D g_list_next(cur_result); + } + g_assert(found); + g_free((char *)((CHSResult *)cur_result->data)->dev_path); + g_free(cur_result->data); + results =3D g_list_delete_link(results, cur_result); + i++; + } + + g_assert(results =3D=3D NULL); + + g_free(buf); +} + +#define MAX_DRIVES 30 + +typedef struct { + char **argv; + int argc; + char **drives; + int n_drives; + int n_scsi_disks; + int n_scsi_controllers; + int n_virtio_disks; +} TestArgs; + +static TestArgs *create_args(void) +{ + TestArgs *args =3D g_malloc0(sizeof(*args)); + args->argv =3D g_new0(char *, ARGV_SIZE); + args->argc =3D append_arg(args->argc, args->argv, + ARGV_SIZE, g_strdup("-nodefaults")); + args->drives =3D g_new0(char *, MAX_DRIVES); + return args; +} + +static void add_drive_with_mbr(TestArgs *args, + MBRpartitions mbr, uint64_t sectors) +{ + char *img_file_name; + char part[300]; + int ret; + + g_assert(args->n_drives < MAX_DRIVES); + + img_file_name =3D create_qcow2_with_mbr(mbr, sectors); + + args->drives[args->n_drives] =3D img_file_name; + ret =3D snprintf(part, sizeof(part), + "-drive file=3D%s,if=3Dnone,format=3Dqcow2,id=3Ddisk%d", + img_file_name, args->n_drives); + g_assert((0 < ret) && (ret <=3D sizeof(part))); + args->argc =3D append_arg(args->argc, args->argv, ARGV_SIZE, g_strdup(= part)); + args->n_drives++; +} + +static void add_ide_disk(TestArgs *args, + int drive_idx, int bus, int unit, int c, int h, i= nt s) +{ + char part[300]; + int ret; + + ret =3D snprintf(part, sizeof(part), + "-device ide-hd,drive=3Ddisk%d,bus=3Dide.%d,unit=3D%d," + "lcyls=3D%d,lheads=3D%d,lsecs=3D%d", + drive_idx, bus, unit, c, h, s); + g_assert((0 < ret) && (ret <=3D sizeof(part))); + args->argc =3D append_arg(args->argc, args->argv, ARGV_SIZE, g_strdup(= part)); +} + +static void add_scsi_controller(TestArgs *args, + const char *type, + const char *bus, + int addr) +{ + char part[300]; + int ret; + + ret =3D snprintf(part, sizeof(part), + "-device %s,id=3Dscsi%d,bus=3D%s,addr=3D%d", + type, args->n_scsi_controllers, bus, addr); + g_assert((0 < ret) && (ret <=3D sizeof(part))); + args->argc =3D append_arg(args->argc, args->argv, ARGV_SIZE, g_strdup(= part)); + args->n_scsi_controllers++; +} + +static void add_scsi_disk(TestArgs *args, + int drive_idx, int bus, + int channel, int scsi_id, int lun, + int c, int h, int s) +{ + char part[300]; + int ret; + + ret =3D snprintf(part, sizeof(part), + "-device scsi-hd,id=3Dscsi-disk%d,drive=3Ddisk%d," + "bus=3Dscsi%d.0," + "channel=3D%d,scsi-id=3D%d,lun=3D%d," + "lcyls=3D%d,lheads=3D%d,lsecs=3D%d", + args->n_scsi_disks, drive_idx, bus, channel, scsi_id, l= un, + c, h, s); + g_assert((0 < ret) && (ret <=3D sizeof(part))); + args->argc =3D append_arg(args->argc, args->argv, ARGV_SIZE, g_strdup(= part)); + args->n_scsi_disks++; +} + +static void add_virtio_disk(TestArgs *args, + int drive_idx, const char *bus, int addr, + int c, int h, int s) +{ + char part[300]; + int ret; + + ret =3D snprintf(part, sizeof(part), + "-device virtio-blk-pci,id=3Dvirtio-disk%d," + "drive=3Ddisk%d,bus=3D%s,addr=3D%d," + "lcyls=3D%d,lheads=3D%d,lsecs=3D%d", + args->n_virtio_disks, drive_idx, bus, addr, c, h, s); + g_assert((0 < ret) && (ret <=3D sizeof(part))); + args->argc =3D append_arg(args->argc, args->argv, ARGV_SIZE, g_strdup(= part)); + args->n_virtio_disks++; +} + +static void test_override(TestArgs *args, CHSResult expected[]) +{ + QTestState *qts; + char *joined_args; + QFWCFG *fw_cfg; + int i; + + joined_args =3D g_strjoinv(" ", args->argv); + + qts =3D qtest_init(joined_args); + fw_cfg =3D pc_fw_cfg_init(qts); + + read_bootdevices(fw_cfg, expected); + + g_free(joined_args); + qtest_quit(qts); + + g_free(fw_cfg); + + for (i =3D 0; i < args->n_drives; i++) { + unlink(args->drives[i]); + free(args->drives[i]); + } + g_free(args->drives); + g_strfreev(args->argv); + g_free(args); +} + +static void test_override_ide(void) +{ + TestArgs *args =3D create_args(); + CHSResult expected[] =3D { + {"/pci@i0cf8/ide@1,1/drive@0/disk@0", {10000, 120, 30} }, + {"/pci@i0cf8/ide@1,1/drive@0/disk@1", {9000, 120, 30} }, + {"/pci@i0cf8/ide@1,1/drive@1/disk@0", {0, 1, 1} }, + {"/pci@i0cf8/ide@1,1/drive@1/disk@1", {1, 0, 0} }, + {NULL, {0, 0, 0} } + }; + add_drive_with_mbr(args, empty_mbr, 1); + add_drive_with_mbr(args, empty_mbr, 1); + add_drive_with_mbr(args, empty_mbr, 1); + add_drive_with_mbr(args, empty_mbr, 1); + add_ide_disk(args, 0, 0, 0, 10000, 120, 30); + add_ide_disk(args, 1, 0, 1, 9000, 120, 30); + add_ide_disk(args, 2, 1, 0, 0, 1, 1); + add_ide_disk(args, 3, 1, 1, 1, 0, 0); + test_override(args, expected); +} + +static void test_override_scsi(void) +{ + TestArgs *args =3D create_args(); + CHSResult expected[] =3D { + {"/pci@i0cf8/scsi@3/channel@0/disk@0,0", {10000, 120, 30} }, + {"/pci@i0cf8/scsi@3/channel@0/disk@1,0", {9000, 120, 30} }, + {"/pci@i0cf8/scsi@3/channel@0/disk@2,0", {1, 0, 0} }, + {"/pci@i0cf8/scsi@3/channel@0/disk@3,0", {0, 1, 0} }, + {NULL, {0, 0, 0} } + }; + add_drive_with_mbr(args, empty_mbr, 1); + add_drive_with_mbr(args, empty_mbr, 1); + add_drive_with_mbr(args, empty_mbr, 1); + add_drive_with_mbr(args, empty_mbr, 1); + add_scsi_controller(args, "lsi53c895a", "pci.0", 3); + add_scsi_disk(args, 0, 0, 0, 0, 0, 10000, 120, 30); + add_scsi_disk(args, 1, 0, 0, 1, 0, 9000, 120, 30); + add_scsi_disk(args, 2, 0, 0, 2, 0, 1, 0, 0); + add_scsi_disk(args, 3, 0, 0, 3, 0, 0, 1, 0); + test_override(args, expected); +} + +static void test_override_scsi_2_controllers(void) +{ + TestArgs *args =3D create_args(); + CHSResult expected[] =3D { + {"/pci@i0cf8/scsi@3/channel@0/disk@0,0", {10000, 120, 30} }, + {"/pci@i0cf8/scsi@3/channel@0/disk@1,0", {9000, 120, 30} }, + {"/pci@i0cf8/scsi@4/channel@0/disk@0,1", {1, 0, 0} }, + {"/pci@i0cf8/scsi@4/channel@0/disk@1,2", {0, 1, 0} }, + {NULL, {0, 0, 0} } + }; + add_drive_with_mbr(args, empty_mbr, 1); + add_drive_with_mbr(args, empty_mbr, 1); + add_drive_with_mbr(args, empty_mbr, 1); + add_drive_with_mbr(args, empty_mbr, 1); + add_scsi_controller(args, "lsi53c895a", "pci.0", 3); + add_scsi_controller(args, "virtio-scsi-pci", "pci.0", 4); + add_scsi_disk(args, 0, 0, 0, 0, 0, 10000, 120, 30); + add_scsi_disk(args, 1, 0, 0, 1, 0, 9000, 120, 30); + add_scsi_disk(args, 2, 1, 0, 0, 1, 1, 0, 0); + add_scsi_disk(args, 3, 1, 0, 1, 2, 0, 1, 0); + test_override(args, expected); +} + +static void test_override_virtio_blk(void) +{ + TestArgs *args =3D create_args(); + CHSResult expected[] =3D { + {"/pci@i0cf8/scsi@3/disk@0,0", {10000, 120, 30} }, + {"/pci@i0cf8/scsi@4/disk@0,0", {9000, 120, 30} }, + {NULL, {0, 0, 0} } + }; + add_drive_with_mbr(args, empty_mbr, 1); + add_drive_with_mbr(args, empty_mbr, 1); + add_virtio_disk(args, 0, "pci.0", 3, 10000, 120, 30); + add_virtio_disk(args, 1, "pci.0", 4, 9000, 120, 30); + test_override(args, expected); +} + +static void test_override_zero_chs(void) +{ + TestArgs *args =3D create_args(); + CHSResult expected[] =3D { + {NULL, {0, 0, 0} } + }; + add_drive_with_mbr(args, empty_mbr, 1); + add_ide_disk(args, 0, 1, 1, 0, 0, 0); + test_override(args, expected); +} + +static void test_override_scsi_hot_unplug(void) +{ + QTestState *qts; + char *joined_args; + QFWCFG *fw_cfg; + QDict *response; + int i; + TestArgs *args =3D create_args(); + CHSResult expected[] =3D { + {"/pci@i0cf8/scsi@2/channel@0/disk@0,0", {10000, 120, 30} }, + {"/pci@i0cf8/scsi@2/channel@0/disk@1,0", {20, 20, 20} }, + {NULL, {0, 0, 0} } + }; + CHSResult expected2[] =3D { + {"/pci@i0cf8/scsi@2/channel@0/disk@1,0", {20, 20, 20} }, + {NULL, {0, 0, 0} } + }; + add_drive_with_mbr(args, empty_mbr, 1); + add_drive_with_mbr(args, empty_mbr, 1); + add_scsi_controller(args, "virtio-scsi-pci", "pci.0", 2); + add_scsi_disk(args, 0, 0, 0, 0, 0, 10000, 120, 30); + add_scsi_disk(args, 1, 0, 0, 1, 0, 20, 20, 20); + + joined_args =3D g_strjoinv(" ", args->argv); + + qts =3D qtest_init(joined_args); + fw_cfg =3D pc_fw_cfg_init(qts); + + read_bootdevices(fw_cfg, expected); + + /* unplug device an restart */ + response =3D qtest_qmp(qts, + "{ 'execute': 'device_del'," + " 'arguments': {'id': 'scsi-disk0' }}"); + g_assert(response); + g_assert(!qdict_haskey(response, "error")); + qobject_unref(response); + response =3D qtest_qmp(qts, + "{ 'execute': 'system_reset', 'arguments': { }}"); + g_assert(response); + g_assert(!qdict_haskey(response, "error")); + qobject_unref(response); + + qtest_qmp_eventwait(qts, "RESET"); + + read_bootdevices(fw_cfg, expected2); + + g_free(joined_args); + qtest_quit(qts); + + g_free(fw_cfg); + + for (i =3D 0; i < args->n_drives; i++) { + unlink(args->drives[i]); + free(args->drives[i]); + } + g_free(args->drives); + g_strfreev(args->argv); + g_free(args); +} + +static void test_override_virtio_hot_unplug(void) +{ + QTestState *qts; + char *joined_args; + QFWCFG *fw_cfg; + QDict *response; + int i; + TestArgs *args =3D create_args(); + CHSResult expected[] =3D { + {"/pci@i0cf8/scsi@2/disk@0,0", {10000, 120, 30} }, + {"/pci@i0cf8/scsi@3/disk@0,0", {20, 20, 20} }, + {NULL, {0, 0, 0} } + }; + CHSResult expected2[] =3D { + {"/pci@i0cf8/scsi@3/disk@0,0", {20, 20, 20} }, + {NULL, {0, 0, 0} } + }; + add_drive_with_mbr(args, empty_mbr, 1); + add_drive_with_mbr(args, empty_mbr, 1); + add_virtio_disk(args, 0, "pci.0", 2, 10000, 120, 30); + add_virtio_disk(args, 1, "pci.0", 3, 20, 20, 20); + + joined_args =3D g_strjoinv(" ", args->argv); + + qts =3D qtest_init(joined_args); + fw_cfg =3D pc_fw_cfg_init(qts); + + read_bootdevices(fw_cfg, expected); + + /* unplug device an restart */ + response =3D qtest_qmp(qts, + "{ 'execute': 'device_del'," + " 'arguments': {'id': 'virtio-disk0' }}"); + g_assert(response); + g_assert(!qdict_haskey(response, "error")); + qobject_unref(response); + response =3D qtest_qmp(qts, + "{ 'execute': 'system_reset', 'arguments': { }}"); + g_assert(response); + g_assert(!qdict_haskey(response, "error")); + qobject_unref(response); + + qtest_qmp_eventwait(qts, "RESET"); + + read_bootdevices(fw_cfg, expected2); + + g_free(joined_args); + qtest_quit(qts); + + g_free(fw_cfg); + + for (i =3D 0; i < args->n_drives; i++) { + unlink(args->drives[i]); + free(args->drives[i]); + } + g_free(args->drives); + g_strfreev(args->argv); + g_free(args); +} + int main(int argc, char **argv) { Backend i; @@ -413,6 +949,21 @@ int main(int argc, char **argv) qtest_add_func("hd-geo/ide/device/mbr/chs", test_ide_device_mbr_chs); qtest_add_func("hd-geo/ide/device/user/chs", test_ide_device_user_chs); qtest_add_func("hd-geo/ide/device/user/chst", test_ide_device_user_chs= t); + if (have_qemu_img()) { + qtest_add_func("hd-geo/override/ide", test_override_ide); + qtest_add_func("hd-geo/override/scsi", test_override_scsi); + qtest_add_func("hd-geo/override/scsi_2_controllers", + test_override_scsi_2_controllers); + qtest_add_func("hd-geo/override/virtio_blk", test_override_virtio_= blk); + qtest_add_func("hd-geo/override/zero_chs", test_override_zero_chs); + qtest_add_func("hd-geo/override/scsi_hot_unplug", + test_override_scsi_hot_unplug); + qtest_add_func("hd-geo/override/virtio_hot_unplug", + test_override_virtio_hot_unplug); + } else { + g_test_message("QTEST_QEMU_IMG not set or qemu-img missing; " + "skipping hd-geo/override/* tests"); + } =20 ret =3D g_test_run(); =20 diff --git a/tests/Makefile.include b/tests/Makefile.include index c79402ab75..728d802dbd 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -794,7 +794,7 @@ tests/ide-test$(EXESUF): tests/ide-test.o $(libqos-pc-o= bj-y) tests/ahci-test$(EXESUF): tests/ahci-test.o $(libqos-pc-obj-y) qemu-img$(E= XESUF) tests/ipmi-kcs-test$(EXESUF): tests/ipmi-kcs-test.o tests/ipmi-bt-test$(EXESUF): tests/ipmi-bt-test.o -tests/hd-geo-test$(EXESUF): tests/hd-geo-test.o +tests/hd-geo-test$(EXESUF): tests/hd-geo-test.o $(libqos-obj-y) tests/boot-order-test$(EXESUF): tests/boot-order-test.o $(libqos-obj-y) tests/boot-serial-test$(EXESUF): tests/boot-serial-test.o $(libqos-obj-y) tests/bios-tables-test$(EXESUF): tests/bios-tables-test.o \ --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list