From nobody Fri Apr 26 19:33:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.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; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1599846832; cv=none; d=zohomail.com; s=zohoarc; b=Gia1Su/6L8xIVaZvupkxzEpYWdgn8W99nli7o+8LXT00sjr3paSo8pLmJC+UWw6R/V0wDBATygEt26YyY/1QSi1yAb39+9RcW6WsGOzaxe5PwHsSwU6z69qzG9TPLBJhxKJQCYKuh+MIjVycq0/kf6SvA+mpLUKs6vUQ4WPNXOo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1599846832; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=NyUzEGeaGgPtV6KAQZjDvQYrp0xE7s4kY9TWUV0FIo4=; b=AUzk6zlQfBSLgsjhICqml3jAyYUAU8KSlgoDSK3qCDSYH1wO7xNSz2olZF2QGy+i3/HWwHUVY1n6aYTOr5I8dnIea6VbyaVHX9Urs7DL9mQP+aibh0Nk4K32rfoEQpdWeCKUnQVHFN9aNaCi0oy1nr6Iup1JM0S5g2ZTHWsX+g4= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com 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 1599846832431153.73411520002503; Fri, 11 Sep 2020 10:53:52 -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-278-t-NouJumPpyttdUkah0laA-1; Fri, 11 Sep 2020 13:53:48 -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 D6516191E2A0; Fri, 11 Sep 2020 17:53:41 +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 A37D42C31E; Fri, 11 Sep 2020 17:53:39 +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 A833D18199F7; Fri, 11 Sep 2020 17:53:33 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 08BHrVST026087 for ; Fri, 11 Sep 2020 13:53:31 -0400 Received: by smtp.corp.redhat.com (Postfix) id AD30E110E94; Fri, 11 Sep 2020 17:53:31 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A6E80112307 for ; Fri, 11 Sep 2020 17:53:28 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 77A5B1021F73 for ; Fri, 11 Sep 2020 17:53:28 +0000 (UTC) Received: from de-smtp-delivery-102.mimecast.com (de-smtp-delivery-102.mimecast.com [51.163.158.102]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-174-m6HF-YO5N_WM0AAgRrkn-A-1; Fri, 11 Sep 2020 13:53:26 -0400 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04lp2056.outbound.protection.outlook.com [104.47.13.56]) (Using TLS) by relay.mimecast.com with ESMTP id de-mta-37-btNnOWsGOky7F3z0ohG8sQ-1; Fri, 11 Sep 2020 19:53:23 +0200 Received: from VI1PR0401MB2429.eurprd04.prod.outlook.com (2603:10a6:800:2c::13) by VI1PR0402MB3661.eurprd04.prod.outlook.com (2603:10a6:803:1d::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3370.17; Fri, 11 Sep 2020 17:53:21 +0000 Received: from VI1PR0401MB2429.eurprd04.prod.outlook.com ([fe80::810a:9a65:c33f:2f15]) by VI1PR0401MB2429.eurprd04.prod.outlook.com ([fe80::810a:9a65:c33f:2f15%7]) with mapi id 15.20.3370.017; Fri, 11 Sep 2020 17:53:21 +0000 Received: from linux-tbji.devlab.prv.suse.com (192.150.153.236) by AM0PR06CA0134.eurprd06.prod.outlook.com (2603:10a6:208:ab::39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3370.16 via Frontend Transport; Fri, 11 Sep 2020 17:53:20 +0000 X-MC-Unique: t-NouJumPpyttdUkah0laA-1 X-MC-Unique: m6HF-YO5N_WM0AAgRrkn-A-1 X-MC-Unique: btNnOWsGOky7F3z0ohG8sQ-1 From: Jim Fehlig To: libvir-list@redhat.com Subject: [PATCH] xen: Don't add dom0 twice on driver reload Date: Fri, 11 Sep 2020 11:53:00 -0600 Message-ID: <20200911175300.26239-1-jfehlig@suse.com> X-ClientProxiedBy: AM0PR06CA0134.eurprd06.prod.outlook.com (2603:10a6:208:ab::39) To VI1PR0401MB2429.eurprd04.prod.outlook.com (2603:10a6:800:2c::13) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-Originating-IP: [192.150.153.236] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5c7ed945-7405-4b24-a5a0-08d8567b9259 X-MS-TrafficTypeDiagnostic: VI1PR0402MB3661: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: AY1GMB8foKmK3vqM36xQrk2ToaVybC3VNwkFzNYRCgYbnR/m2iVdZXs9PmFjloO+EzDC4dWb4PmyRBOlOuCE2zpQOwdsasrxsTZLZjtNJWUu1TfeCOeepa3pUA8Xifs9ewxqHd1AWyj2rV1QmiwbmTS8dzt1AMQ++EHKBIiHOwLFQXiDHY4BX2s9ekM+RTSwFy+Uouj0+lxojqsVLPsB0Lj6N5F2Bwc0bMfL5d4JHzvgYEh4rNk3OPVg4F9S4v7xhX1bbjMu0Yb1M+qYjjjnQ/Rs80ndm72uUbUS57brAOqpB5IpFFXjwiGBUG1FGYBwmoVRUCPmqblRjjMLIZmprQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR0401MB2429.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(376002)(136003)(366004)(396003)(346002)(39860400002)(7696005)(52116002)(4326008)(5660300002)(36756003)(66946007)(107886003)(86362001)(2906002)(8676002)(6916009)(66556008)(6666004)(66476007)(8936002)(1076003)(956004)(186003)(316002)(2616005)(26005)(83380400001)(478600001)(16526019)(6486002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: kvCKWnkQCza/dN4BpoocyDuDy0TyykiOSf5mA/ma2MTu+UXD4bDvYRSWybDqU6E5kTiaD/kRHVqmdbYcIht3jiC3UnmUvOL2ECDG7x15A+Cj5kj+PN7rNOftugTH9roVl4kb2+D+v/zSXpaYACvqhfd2sVS1bdiVkBTfKDcXaC6a5b+4/Ii3235WatWiLEHQcb9p/UVqDQi4LXcnFNbgWkDfy/PcBn3/KYAlOVhvE/oIbqavpK7x8mTiKzTiC5Dn4ZpMcHVE3Xrk6sOn+UY18nxNeNX7rei0/ZTaCIeZp/bFUpNhd4agcbiBOKLI+3TbnPoJnwRw/O1HvjH1hnOtqBDEdwGPVj6vk2wMH77P3tJCQUCFuvhErMa0h02wu21tVNedEOfHkoc/t5Xqed3LOEJMrNjZhneKsT0IoioZXcUNIl58RbYOMqYcLRihX97gh9DMxrwIi5EN8G6SbUfO/Ffp8mLihXoc/nSJIhLS5uQq324dz4B3Dxycox6VJDClmg1zS5SLZgJdrKw2RqOJmixlZnKnh2tkt34DUqTw9rDYeEBuHbqeO9W5iJrVRF5Wa2ENn+J3q8SqG8oeX/Zg2g48R8OSQtMQ8JA+3Rr7akXDbjOHLv49FOq7rgdL+Iw0ay2mJs2+kdFzSRxKOXw3uw== X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5c7ed945-7405-4b24-a5a0-08d8567b9259 X-MS-Exchange-CrossTenant-AuthSource: VI1PR0401MB2429.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Sep 2020 17:53:21.2638 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: /pzmp6kNDURjePi1CtbZeJu2JMwRLhf7eILo16XNK1MKLfgj4GaVDbKiDriVv/07laDZx0MsAytM1CUsQzzjNw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB3661 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false; X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 08BHrVST026087 X-loop: libvir-list@redhat.com 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 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0.003 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When the xen driver loads, it probes libxl for some info about dom0 and adds it to the virDomainObjList. The driver then looks for any domains in stateDir and if they are still alive adds them to the list as well. This logic is a bit flawed wrt handling driver reload and causes the following error internal error: unexpected domain Domain-0 already exists A simple fix is to load all domains from stateDir first and then only add dom0 if needed. Signed-off-by: Jim Fehlig Reviewed-by: J=C3=A1n Tomko --- src/libxl/libxl_driver.c | 46 +++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index 161a6882f3..083738871d 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -604,27 +604,33 @@ libxlAddDom0(libxlDriverPrivatePtr driver) goto cleanup; } =20 - if (!(def =3D virDomainDefNew())) - goto cleanup; + /* + * On a driver reload dom0 will already exist. On host restart it must + * created. + */ + if ((vm =3D virDomainObjListFindByID(driver->domains, 0)) =3D=3D NULL)= { + if (!(def =3D virDomainDefNew())) + goto cleanup; =20 - def->id =3D 0; - def->virtType =3D VIR_DOMAIN_VIRT_XEN; - def->name =3D g_strdup("Domain-0"); + def->id =3D 0; + def->virtType =3D VIR_DOMAIN_VIRT_XEN; + def->name =3D g_strdup("Domain-0"); =20 - def->os.type =3D VIR_DOMAIN_OSTYPE_XEN; + def->os.type =3D VIR_DOMAIN_OSTYPE_XEN; =20 - if (virUUIDParse("00000000-0000-0000-0000-000000000000", def->uuid) < = 0) - goto cleanup; + if (virUUIDParse("00000000-0000-0000-0000-000000000000", def->uuid= ) < 0) + goto cleanup; =20 - if (!(vm =3D virDomainObjListAdd(driver->domains, def, - driver->xmlopt, - 0, - NULL))) - goto cleanup; - def =3D NULL; + if (!(vm =3D virDomainObjListAdd(driver->domains, def, + driver->xmlopt, + 0, + NULL))) + goto cleanup; + + vm->persistent =3D 1; + virDomainObjSetState(vm, VIR_DOMAIN_RUNNING, VIR_DOMAIN_RUNNING_BO= OTED); + } =20 - vm->persistent =3D 1; - virDomainObjSetState(vm, VIR_DOMAIN_RUNNING, VIR_DOMAIN_RUNNING_BOOTED= ); if (virDomainDefSetVcpusMax(vm->def, d_info.vcpu_max_id + 1, driver->x= mlopt)) goto cleanup; =20 @@ -783,10 +789,6 @@ libxlStateInitialize(bool privileged, if (!(libxl_driver->xmlopt =3D libxlCreateXMLConf(libxl_driver))) goto error; =20 - /* Add Domain-0 */ - if (libxlAddDom0(libxl_driver) < 0) - goto error; - /* Load running domains first. */ if (virDomainObjListLoadAllConfigs(libxl_driver->domains, cfg->stateDir, @@ -796,6 +798,10 @@ libxlStateInitialize(bool privileged, NULL, NULL) < 0) goto error; =20 + /* Add Domain-0 */ + if (libxlAddDom0(libxl_driver) < 0) + goto error; + libxlReconnectDomains(libxl_driver); =20 /* Then inactive persistent configs */ --=20 2.28.0