From patchwork Sun Apr 12 22:02:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Rosbrook X-Patchwork-Id: 11484819 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D1A0C13B2 for ; Sun, 12 Apr 2020 22:04:18 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AD76420644 for ; Sun, 12 Apr 2020 22:04:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ADa+qUn5" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AD76420644 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jNkgm-0003EM-6J; Sun, 12 Apr 2020 22:02:52 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jNkgl-0003EF-JE for xen-devel@lists.xenproject.org; Sun, 12 Apr 2020 22:02:51 +0000 X-Inumbo-ID: 57e82190-7d09-11ea-b58d-bc764e2007e4 Received: from mail-qv1-xf43.google.com (unknown [2607:f8b0:4864:20::f43]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 57e82190-7d09-11ea-b58d-bc764e2007e4; Sun, 12 Apr 2020 22:02:47 +0000 (UTC) Received: by mail-qv1-xf43.google.com with SMTP id q73so3616609qvq.2 for ; Sun, 12 Apr 2020 15:02:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=EYuJy7ICD2kfNTKAB5E+SVFDtpQL5zTM1dMZH8Nfw14=; b=ADa+qUn5NQzV1qu4k6654JciCe63UHdb3SDQW9LOG4BvO3u9NLetoxp0KDUSNTWaZf jKCsdqZxSu2snqj/vc4AULhFMgKyThQMhgmvUYdYRFvuPFbA6yiVhO1izoacj1i8toQl XeNMrwTWDu33P2mT3SbSyQ4E0GE8gsVshcSdYpdbuGLYBU4u9yXTC6Fz4AMhx9E5hI6v 7C0B7Z/TWEsx9/pLK7Kanm/o4JsW6e76sRiDuaHAQGFrd3PS05vdEhM0BJE3KLzSDhng 4UU80/mYEMJsZm8YvEe0ggSQ0mCcCJetaT61TDJW9uys377wmFyfaBdOjgRURcDMp8Mv Ssrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=EYuJy7ICD2kfNTKAB5E+SVFDtpQL5zTM1dMZH8Nfw14=; b=uXtcnXXXR7yzBMzektehxuZMWVuOWZINBrrODBaq18TsCUgI1QRCp+zlK3r2VWeX1F xpNrg2fqE5GooXCrCR+xNdTAoPSQwy9ZsozqlNSXI9b/xTa46kSPqlwNG+oVIuLlIQ6h ua8EPG2Ps+Qy6Qwug74Gk7E7Vmot+Qc2iOvkVVeXxJ5VXXMR0zru2kAEn1gjkZLDbWXe KgE3WQtAE2OTfN/7JVgw380yrKRbshQwiAjvzbNuBZoI3Y4UuRw3q7cZgg9G0wEHSqV1 UKJIVy6Urag3MonBXBPXaKzyYn0J0jRl3tI9Ejnul4NZyLZALDwP7gJXD2NHWs/FMmQW 0TCQ== X-Gm-Message-State: AGi0PuadroHCD4lUZlsZRgC1Sw+p+NMszvln0TyxKtUeMpsjRhnogiNM LNgGaRKHW7+IjvjRGWc0b9WANF7s X-Google-Smtp-Source: APiQypKOSKazjyYGBfbvqjoDULajgQ4tkzHcgT01amGgnMryarJC3NHwfSK8I5N3KYiDpNCYXdpyVQ== X-Received: by 2002:a05:6214:1e5:: with SMTP id c5mr14095258qvu.79.1586728966528; Sun, 12 Apr 2020 15:02:46 -0700 (PDT) Received: from four.lan (cpe-67-241-56-252.twcny.res.rr.com. [67.241.56.252]) by smtp.gmail.com with ESMTPSA id s14sm3691128qts.70.2020.04.12.15.02.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Apr 2020 15:02:45 -0700 (PDT) From: Nick Rosbrook X-Google-Original-From: Nick Rosbrook To: xen-devel@lists.xenproject.org Subject: [PATCH 1/4] golang/xenlight: add NameToDomid and DomidToName util functions Date: Sun, 12 Apr 2020 18:02:39 -0400 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Nick Rosbrook , Ian Jackson , George Dunlap , Wei Liu Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Many exported functions in xenlight require a domid as an argument. Make it easier for package users to use these functions by adding wrappers for the libxl utility functions libxl_name_to_domid and libxl_domid_to_name. Signed-off-by: Nick Rosbrook --- tools/golang/xenlight/xenlight.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tools/golang/xenlight/xenlight.go b/tools/golang/xenlight/xenlight.go index 3f1b0baa0c..8492bcec4e 100644 --- a/tools/golang/xenlight/xenlight.go +++ b/tools/golang/xenlight/xenlight.go @@ -20,6 +20,7 @@ package xenlight #cgo LDFLAGS: -lxenlight -lyajl -lxentoollog #include #include +#include */ import "C" @@ -124,6 +125,28 @@ func (ctx *Context) Close() error { type Domid uint32 +// NameToDomid returns the Domid for a domain, given its name, if it exists. +func (Ctx *Context) NameToDomid(name string) (Domid, error) { + var domid C.uint32_t + + cname := C.CString(name) + defer C.free(unsafe.Pointer(cname)) + + if ret := C.libxl_name_to_domid(Ctx.ctx, cname, &domid); ret != 0 { + return ^Domid(0), Error(ret) + } + + return Domid(domid), nil +} + +// DomidToName returns the name for a domain, given its domid. +func (Ctx *Context) DomidToName(domid Domid) string { + cname := C.libxl_domid_to_name(Ctx.ctx, C.uint32_t(domid)) + defer C.free(unsafe.Pointer(cname)) + + return C.GoString(cname) +} + // Devid is a device ID. type Devid int From patchwork Sun Apr 12 22:02:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Rosbrook X-Patchwork-Id: 11484817 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F0EF813B2 for ; Sun, 12 Apr 2020 22:04:14 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CCB2B20644 for ; Sun, 12 Apr 2020 22:04:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="MX/Q6FfL" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CCB2B20644 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jNkgr-0003F9-Et; Sun, 12 Apr 2020 22:02:57 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jNkgq-0003Et-JU for xen-devel@lists.xenproject.org; Sun, 12 Apr 2020 22:02:56 +0000 X-Inumbo-ID: 58aeefa0-7d09-11ea-b4f4-bc764e2007e4 Received: from mail-qv1-xf43.google.com (unknown [2607:f8b0:4864:20::f43]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 58aeefa0-7d09-11ea-b4f4-bc764e2007e4; Sun, 12 Apr 2020 22:02:48 +0000 (UTC) Received: by mail-qv1-xf43.google.com with SMTP id v38so3606207qvf.6 for ; Sun, 12 Apr 2020 15:02:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=C5Z/EnHHQ5Xpy674QajNb7wsUJqqHSMnmxzzSFt1iQQ=; b=MX/Q6FfLCQ5XTurVk020jRSRyuuilXNSsBai31olDuDsraqXF1lGZzQn+BwtH4lbMF q0Rj6sCHgYga6RnOGwPn7u8CXcW5jo/Z2H+x18AFRaRvaPzNjE38FqBGQwOZ4Q3ETFPX M4fraq3B0ZLxY+3TFH8jWYClekWROyeb/r3zs9FnIQMz/2Gp+RzEZcc6HvlHt2UyAJdt KAt1dBVyuqs75pE2e+KR1FiKf9TBJcilmzCsd1Eep8lAz5RzbRBrBsJLxZSzQm46ncqO zGOyFM2U20EgHH5t9gn9OMS6Daz5w4J1oVeLLETydITTYhPtWykgvp3iMXdjyb0GeoGY VcQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=C5Z/EnHHQ5Xpy674QajNb7wsUJqqHSMnmxzzSFt1iQQ=; b=n831loBBNNqke7AqYfna+NLcxz3BNkMBQrPT/oGJXB6/ww/xUWcxnvC2sGA4OJSLuN XsIZ26TfNl1gO9aZxIeJwhj3u/D1IB7+TZQ6VC5tgwUsEMvnsBkJiqfwI+BwtWZK+CN3 OcOfcTtvwHn4NcnUZNhYs08Wpv7/GwPd+CDZibdwvnNxiUxKooxJSKROdMhoWQaOP011 8IYVmxPpgyPVxzliED6qsjX1sNpL8jnKi5qrg/mVJQt1TsqowNIkXwLiAv9FpAOA6Cc3 DyzKWNvf2lYdpsvb4G9CZyUrsZQCAq2W2RxSyhsz6JgCHEM9SV/Q0uTHX3f7nuZC7SPT rrgw== X-Gm-Message-State: AGi0PuaiQ8bAUbsoQMY1naeqeG25nnzVslzh+OsFWoRpcaUdMWsuGh8x Y1CbdeCcFFSb86oeilzMNazccuZA X-Google-Smtp-Source: APiQypIS/w2ctfqHkQIrT294kCGqJR6TnqQmLIUCoTCg63aIBkpeaw0jq/qYc2pAYJtgwrZmFDMcaQ== X-Received: by 2002:ad4:5184:: with SMTP id b4mr14550655qvp.221.1586728967851; Sun, 12 Apr 2020 15:02:47 -0700 (PDT) Received: from four.lan (cpe-67-241-56-252.twcny.res.rr.com. [67.241.56.252]) by smtp.gmail.com with ESMTPSA id s14sm3691128qts.70.2020.04.12.15.02.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Apr 2020 15:02:47 -0700 (PDT) From: Nick Rosbrook X-Google-Original-From: Nick Rosbrook To: xen-devel@lists.xenproject.org Subject: [PATCH 2/4] golang/xenlight: add DeviceNicAdd/Remove wrappers Date: Sun, 12 Apr 2020 18:02:40 -0400 Message-Id: <87323a6eb60fd908ea2f792c9754cb88b283c5a6.1586727061.git.rosbrookn@ainfosec.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Nick Rosbrook , Ian Jackson , George Dunlap , Wei Liu Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Add DeviceNicAdd and DeviceNicRemove as wrappers for libxl_device_nic_add and libxl_device_nic_remove. Signed-off-by: Nick Rosbrook Reviewed-by: George Dunlap --- tools/golang/xenlight/xenlight.go | 34 +++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/tools/golang/xenlight/xenlight.go b/tools/golang/xenlight/xenlight.go index 8492bcec4e..a56f913b81 100644 --- a/tools/golang/xenlight/xenlight.go +++ b/tools/golang/xenlight/xenlight.go @@ -1068,3 +1068,37 @@ func (Ctx *Context) PrimaryConsoleGetTty(domid uint32) (path string, err error) path = C.GoString(cpath) return } + +// DeviceNicAdd adds a nic to a domain. +func (Ctx *Context) DeviceNicAdd(domid Domid, nic *DeviceNic) error { + var cnic C.libxl_device_nic + + if err := nic.toC(&cnic); err != nil { + return err + } + defer C.libxl_device_nic_dispose(&cnic) + + ret := C.libxl_device_nic_add(Ctx.ctx, C.uint32_t(domid), &cnic, nil) + if ret != 0 { + return Error(ret) + } + + return nil +} + +// DeviceNicRemove removes a nic from a domain. +func (Ctx *Context) DeviceNicRemove(domid Domid, nic *DeviceNic) error { + var cnic C.libxl_device_nic + + if err := nic.toC(&cnic); err != nil { + return err + } + defer C.libxl_device_nic_dispose(&cnic) + + ret := C.libxl_device_nic_remove(Ctx.ctx, C.uint32_t(domid), &cnic, nil) + if ret != 0 { + return Error(ret) + } + + return nil +} From patchwork Sun Apr 12 22:02:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Rosbrook X-Patchwork-Id: 11484821 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 50F7792C for ; Sun, 12 Apr 2020 22:04:26 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2C55B20644 for ; Sun, 12 Apr 2020 22:04:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mbXds/yM" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2C55B20644 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jNkgw-0003Gh-Ng; Sun, 12 Apr 2020 22:03:02 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jNkgv-0003GM-Jg for xen-devel@lists.xenproject.org; Sun, 12 Apr 2020 22:03:01 +0000 X-Inumbo-ID: 597b2f70-7d09-11ea-83d8-bc764e2007e4 Received: from mail-qt1-x842.google.com (unknown [2607:f8b0:4864:20::842]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 597b2f70-7d09-11ea-83d8-bc764e2007e4; Sun, 12 Apr 2020 22:02:49 +0000 (UTC) Received: by mail-qt1-x842.google.com with SMTP id z90so5859322qtd.10 for ; Sun, 12 Apr 2020 15:02:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=xQseH+w2yE4yJYVdULOAupSEFUC15dIoKjSVtzW1RYQ=; b=mbXds/yMXXI77oozv1GEuKTLmqLlNMAuQy5DVvhXLICyJHvTtY/UBdkRokROlrE5iu ZZg4GrhROG5Aan+JfINU5GFQWhgErhwCAi7xcsj4m55nmWOpFSrkB2u7rY3KWAusdXuR XZErv2fJ0Jut+rjwSbd8tBDO9H+zCBFH+oNY+hOnyAYPjKlxDAglE3gAnu4a7NBU8s+7 tF342TiNmwKvsMG2apnmqUyxALTHOaro2HI41a/EFWeZcQpWLeMlD2USNh3BpcZ47Tqj Gmebw/A5qgWNivdalS8VnZy62AHTOlnCpt0EDd3PB3znoZJ9wtMDzrgxxiHNTQNd3EQb aAoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=xQseH+w2yE4yJYVdULOAupSEFUC15dIoKjSVtzW1RYQ=; b=lx58xuDUR7Nohsqs/Bxt30Jr9+tvusQ6dZ6bfc7zb44sBkyv8/F3ZYsTdQr5GOCYTa vbPsex0jLSahZ242UcA42tylGmIM/iOnO5P1oScDVwamieQDbLFFuIgzdl1jPLwC0S5N loycoacAo4jisazzg2KPRccYB87r7441wjbyikN/clPSLa5JBbP28b1wFdHrff9xZtT/ yXq7foFiKOst/WiduSNQlpU3Dova2T6o773R2y2UhgfAvggbGfqBw+Lxgk8rYWy9ZM2A BUQtxDkzOX1pu7pZlYadQplb//osnh8t5HeSSPiUSdVGmLe1ERQg8kfM+mF05eap02Zc 2sbQ== X-Gm-Message-State: AGi0PubBP5zaFYg5ge7OM6B1RiQu9li5X++U5uZRSOe4QDja3NjeOPH6 0H3JCpRzK1RmR5vAjTJhsqfX7q6o X-Google-Smtp-Source: APiQypIacsGj1YC3T0eoqwBQppzvgi5VJQQlNAtetUcTtfDHNvyORLAg2oT9k2X/6y9Ww/MHRv7E5w== X-Received: by 2002:ac8:6d23:: with SMTP id r3mr8470311qtu.84.1586728969148; Sun, 12 Apr 2020 15:02:49 -0700 (PDT) Received: from four.lan (cpe-67-241-56-252.twcny.res.rr.com. [67.241.56.252]) by smtp.gmail.com with ESMTPSA id s14sm3691128qts.70.2020.04.12.15.02.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Apr 2020 15:02:48 -0700 (PDT) From: Nick Rosbrook X-Google-Original-From: Nick Rosbrook To: xen-devel@lists.xenproject.org Subject: [PATCH 3/4] golang/xenlight: add DevicePciAdd/Remove wrappers Date: Sun, 12 Apr 2020 18:02:41 -0400 Message-Id: <7f03220c9db0a377cd26c0c96d8a10981ec47282.1586727061.git.rosbrookn@ainfosec.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Nick Rosbrook , Ian Jackson , George Dunlap , Wei Liu Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Add DevicePciAdd and DevicePciRemove as wrappers for libxl_device_pci_add and libxl_device_pci remove. Signed-off-by: Nick Rosbrook Reviewed-by: George Dunlap --- tools/golang/xenlight/xenlight.go | 34 +++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/tools/golang/xenlight/xenlight.go b/tools/golang/xenlight/xenlight.go index a56f913b81..c94b046667 100644 --- a/tools/golang/xenlight/xenlight.go +++ b/tools/golang/xenlight/xenlight.go @@ -1102,3 +1102,37 @@ func (Ctx *Context) DeviceNicRemove(domid Domid, nic *DeviceNic) error { return nil } + +// DevicePciAdd is used to passthrough a PCI device to a domain. +func (Ctx *Context) DevicePciAdd(domid Domid, pci *DevicePci) error { + var cpci C.libxl_device_pci + + if err := pci.toC(&cpci); err != nil { + return err + } + defer C.libxl_device_pci_dispose(&cpci) + + ret := C.libxl_device_pci_add(Ctx.ctx, C.uint32_t(domid), &cpci, nil) + if ret != 0 { + return Error(ret) + } + + return nil +} + +// DevicePciRemove removes a PCI device from a domain. +func (Ctx *Context) DevicePciRemove(domid Domid, pci *DevicePci) error { + var cpci C.libxl_device_pci + + if err := pci.toC(&cpci); err != nil { + return err + } + defer C.libxl_device_pci_dispose(&cpci) + + ret := C.libxl_device_pci_remove(Ctx.ctx, C.uint32_t(domid), &cpci, nil) + if ret != 0 { + return Error(ret) + } + + return nil +} From patchwork Sun Apr 12 22:02:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nick Rosbrook X-Patchwork-Id: 11484823 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3A5A492C for ; Sun, 12 Apr 2020 22:04:30 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1623520644 for ; Sun, 12 Apr 2020 22:04:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mTZ++ght" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1623520644 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jNkh1-0003IG-0J; Sun, 12 Apr 2020 22:03:07 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jNkh0-0003I2-KT for xen-devel@lists.xenproject.org; Sun, 12 Apr 2020 22:03:06 +0000 X-Inumbo-ID: 5a4a57c8-7d09-11ea-b4f4-bc764e2007e4 Received: from mail-qt1-x841.google.com (unknown [2607:f8b0:4864:20::841]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 5a4a57c8-7d09-11ea-b4f4-bc764e2007e4; Sun, 12 Apr 2020 22:02:51 +0000 (UTC) Received: by mail-qt1-x841.google.com with SMTP id o10so5871336qtr.6 for ; Sun, 12 Apr 2020 15:02:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=NmfxgsNf5K3mmZ2//UrmLn1WOxxwaw+HLr7AjrHfqbU=; b=mTZ++ghtU3U7tbwnc840P55CJPNfQ0mqSErJPkR0X0pz/kLBYCkRiAqgqIZp6SpFMZ 4K6o1jBamZWs9TZJWsZcteuRYhhWDYMFi6XPDVJ349EcHyvgRphuC5Bf8L3+wGBBl+ys ZFBRHGodTmxTiBM8BsWFv3ZdQHHiOGOzMMamo2M/eeFW9L9dPsyeFegM3K1frkkLaGgM f1lHnLuiu6DXEx2wxhg+jB2/4Zet6gYXkWRVAEMbF6UJk74hIBHfnf4pndG0xsYxGnlr /0SjvsMVPdQyWUufGVWD0dntbxMr8BkPaypY/5VvZ/F39LeNkkvfQdnuC0AJJPDYzLdJ ePjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=NmfxgsNf5K3mmZ2//UrmLn1WOxxwaw+HLr7AjrHfqbU=; b=fczmwOQMl54BD2932+XPCEfC8IoImwSidKUZ5LaMn+kXG0vuAh9riDHMo5FCLMA/MB gqvtu7kSNPC3PAO73UuadD8zSmFIuhSg7ELSPdiRh2oL/eDcbZns1I1SkiZiObcZGwgS Kt869qDZZNVRV3tsiG0L56GWg/ldxQLGmAHKlziCHllCYZJgq+Dy0jbPmV0hYAUfjUQH +2uQWCVNrLv8hUp84F5p+X3yp0ZAdAM8/uEKkGj54sFcdto3x+hcFNnk7bt8S0veWcyH dxk3MEcBTvmxiAaOf80i5k4ZQGBLLJmR4IreoDrc66QKV9chMJUgc4Ze79zSolXlGfgV KijA== X-Gm-Message-State: AGi0PuZc4HzUuo1z65Sh9p/oqbfSSnOdGwPr+HjeaujN9X97x9siVr10 u0etOeHkJs27mIf2e6oNqZtuILJ/ X-Google-Smtp-Source: APiQypJEOq8uosf+DmUlGSZcUywLdkAauXybwVTg5BSsXmX6ad/GcygkPdbJtukykyKqpaopmaqZ0w== X-Received: by 2002:ac8:43c3:: with SMTP id w3mr9103038qtn.350.1586728970375; Sun, 12 Apr 2020 15:02:50 -0700 (PDT) Received: from four.lan (cpe-67-241-56-252.twcny.res.rr.com. [67.241.56.252]) by smtp.gmail.com with ESMTPSA id s14sm3691128qts.70.2020.04.12.15.02.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Apr 2020 15:02:49 -0700 (PDT) From: Nick Rosbrook X-Google-Original-From: Nick Rosbrook To: xen-devel@lists.xenproject.org Subject: [PATCH 4/4] golang/xenlight: add DeviceUsbdevAdd/Remove wrappers Date: Sun, 12 Apr 2020 18:02:42 -0400 Message-Id: <1fcd31482f5183f29e9d949c6e17183b6b101c8b.1586727061.git.rosbrookn@ainfosec.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Nick Rosbrook , Ian Jackson , George Dunlap , Wei Liu Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Add DeviceUsbdevAdd and DeviceUsbdevRemove as wrappers for libxl_device_usbdev_add and libxl_device_usbdev_remove. Signed-off-by: Nick Rosbrook Reviewed-by: George Dunlap --- tools/golang/xenlight/xenlight.go | 34 +++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/tools/golang/xenlight/xenlight.go b/tools/golang/xenlight/xenlight.go index c94b046667..2d45d2bd48 100644 --- a/tools/golang/xenlight/xenlight.go +++ b/tools/golang/xenlight/xenlight.go @@ -1136,3 +1136,37 @@ func (Ctx *Context) DevicePciRemove(domid Domid, pci *DevicePci) error { return nil } + +// DeviceUsbdevAdd adds a USB device to a domain. +func (Ctx *Context) DeviceUsbdevAdd(domid Domid, usbdev *DeviceUsbdev) error { + var cusbdev C.libxl_device_usbdev + + if err := usbdev.toC(&cusbdev); err != nil { + return err + } + defer C.libxl_device_usbdev_dispose(&cusbdev) + + ret := C.libxl_device_usbdev_add(Ctx.ctx, C.uint32_t(domid), &cusbdev, nil) + if ret != 0 { + return Error(ret) + } + + return nil +} + +// DeviceUsbdevRemove removes a USB device from a domain. +func (Ctx *Context) DeviceUsbdevRemove(domid Domid, usbdev *DeviceUsbdev) error { + var cusbdev C.libxl_device_usbdev + + if err := usbdev.toC(&cusbdev); err != nil { + return err + } + defer C.libxl_device_usbdev_dispose(&cusbdev) + + ret := C.libxl_device_usbdev_remove(Ctx.ctx, C.uint32_t(domid), &cusbdev, nil) + if ret != 0 { + return Error(ret) + } + + return nil +}