From nobody Sun May 5 14:19:49 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 ARC-Seal: i=1; a=rsa-sha256; t=1573595127; cv=none; d=zoho.com; s=zohoarc; b=kASvjayjYWpYy9z1vhWNPsIRs9WLM1vFyLHv7ktRBfMWNPF6uA5cjL3pkyBeUyX+98l9oLOOs5MZhVpq0Fs/RGSuK/z3Xws8uPW/Zvzj84wUr8DD7ofrL1pxvFBZysHLGKvh2cOVYRaVnzU9wGKiPLgadrFTISYRGbdk2Gca1po= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573595127; 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=GwpSCHQYdyJ1OIULiofZixGUfDNOVtkOMAzqdW+IKas=; b=eTWqFqeF4gSA/knLw2fxIzkohsBPziQqo1NZDkVXB3x4LZ1JRDoqOy0bKI6NkAQmIQJSCSmsWwpQJzKqkJYftf73+FQWQuIGwXhHbdbVZdLOGZK9Y47oY4lEW4WgPVqiLeU8cEQpG7aTW0EJ9dwrqJDTiGa3Km3IBXp8DtiJB6o= 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 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 1573595127886504.6961822637011; Tue, 12 Nov 2019 13:45:27 -0800 (PST) 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-376-nmv6FleeN0uhTTMq0iMvkw-1; Tue, 12 Nov 2019 16:45:24 -0500 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 779701852E23; Tue, 12 Nov 2019 21:45:15 +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 E1F554EE11; Tue, 12 Nov 2019 21:45:14 +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 759574E566; Tue, 12 Nov 2019 21:45:14 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xACLitdW027037 for ; Tue, 12 Nov 2019 16:44:56 -0500 Received: by smtp.corp.redhat.com (Postfix) id D441A10D16AC; Tue, 12 Nov 2019 21:44:55 +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 D013A10D16AE for ; Tue, 12 Nov 2019 21:44:54 +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 774FF101A55E for ; Tue, 12 Nov 2019 21:44:54 +0000 (UTC) Received: from balrog.mythic-beasts.com (balrog.mythic-beasts.com [46.235.227.24]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-180-reVDepgpPoWDoSieUFYY7A-1; Tue, 12 Nov 2019 16:44:51 -0500 Received: from [199.195.250.187] (port=45790 helo=hermes.aosc.io) by balrog.mythic-beasts.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92.3) (envelope-from ) id 1iUdxx-0008Er-J1; Tue, 12 Nov 2019 21:44:49 +0000 Received: from liushuyu.lan (unknown [172.22.1.1]) by hermes.aosc.io (Postfix) with ESMTPS id BA5BA41B73; Tue, 12 Nov 2019 21:44:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573595126; 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=GwpSCHQYdyJ1OIULiofZixGUfDNOVtkOMAzqdW+IKas=; b=GTXx/qMedWhnq8ltFeiNgcETqDrsc7v1ClzBUdoHqk5ArXtoZvDtJGFV+rX6Xxkzhzs8FM MXMIiIeVYC1Hf2VoNjs+QSTCqtJjfulqXFg+H80/ODp4kW+rinfR3ZRJkHFYc0/oLHNJKu UCcBnpMEcTrfqUqEXof9hZZCMySph/k= From: Zixing Liu To: libvir-list@redhat.com Date: Tue, 12 Nov 2019 14:44:42 -0700 Message-Id: <20191112214445.14541-2-liushuyu@aosc.io> In-Reply-To: <20191112214445.14541-1-liushuyu@aosc.io> References: <20191112214445.14541-1-liushuyu@aosc.io> MIME-Version: 1.0 X-Spamd-Result: default: False [2.90 / 15.00] R_MISSING_CHARSET(2.50)[] BROKEN_CONTENT_TYPE(1.50)[] REPLY(-2.00)[] MID_CONTAINS_FROM(1.00)[] TO_DN_ALL(0.00)[] FROM_EQ_ENVFROM(0.00)[] MAILCOW_MOO(0.00)[] FROM_HAS_DN(0.00)[] TO_MATCH_ENVRCPT_ALL(0.00)[] RCPT_COUNT_THREE(0.00)[3] RCVD_COUNT_TWO(0.00)[2] MIME_GOOD(-0.10)[text/plain] X-Rspamd-Server: rspamd X-Rspamd-Scan-Time: 0.01 X-Rspamd-Queue-ID: BA5BA41B73 X-BlackCat-Spam-Score: 50 X-Spam-Status: No, score=5.0 X-MC-Unique: reVDepgpPoWDoSieUFYY7A-1 X-MC-Unique: nmv6FleeN0uhTTMq0iMvkw-1 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id xACLitdW027037 X-loop: libvir-list@redhat.com Cc: Zixing Liu , sahid.ferdjaoui@canonical.com Subject: [libvirt] [PATCH Rust 1/4] libvirt-rust: stream: add more functions in stream 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-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" * added new functions: virStreamNew virStreamEventUpdateCallback virStreamEventRemoveCallback * added new constants: VIR_STREAM_NONBLOCK * added new types/aliases: StreamFlags * changed the previous `new` associate function to `from_ptr` to avoid naming conflicts * added basic tests to test the creation of Stream struct (can not test the correctness of virStreamEventRemoveCallback and virStreamEventUpdateCallback due to "unsupported by the connection driver") Signed-off-by: Zixing Liu --- src/stream.rs | 43 +++++++++++++++++++++++++++++++++++++++++-- tests/stream.rs | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+), 2 deletions(-) create mode 100644 tests/stream.rs diff --git a/src/stream.rs b/src/stream.rs index 2ca5d0b..de272ab 100644 --- a/src/stream.rs +++ b/src/stream.rs @@ -18,8 +18,9 @@ =20 extern crate libc; =20 +use connect::Connect; +use connect::sys::virConnectPtr; use std::convert::TryFrom; -use std::str; =20 use error::Error; =20 @@ -32,6 +33,9 @@ pub mod sys { =20 #[link(name =3D "virt")] extern "C" { + fn virStreamNew(c: virConnectPtr, + flags: libc::c_uint) + -> sys::virStreamPtr; fn virStreamSend(c: sys::virStreamPtr, data: *const libc::c_char, nbytes: libc::size_t) @@ -43,6 +47,9 @@ extern "C" { fn virStreamFree(c: sys::virStreamPtr) -> libc::c_int; fn virStreamAbort(c: sys::virStreamPtr) -> libc::c_int; fn virStreamFinish(c: sys::virStreamPtr) -> libc::c_int; + fn virStreamEventUpdateCallback(c: sys::virStreamPtr, + events: libc::c_int) -> libc::c_int; + fn virStreamEventRemoveCallback(c: sys::virStreamPtr) -> libc::c_int; } =20 pub type StreamEventType =3D self::libc::c_uint; @@ -51,6 +58,9 @@ pub const VIR_STREAM_EVENT_WRITABLE: StreamEventType =3D = (1 << 1); pub const VIR_STREAM_EVENT_ERROR: StreamEventType =3D (1 << 2); pub const VIR_STREAM_EVENT_HANGUP: StreamEventType =3D (1 << 3); =20 +pub type StreamFlags =3D self::libc::c_uint; +pub const VIR_STREAM_NONBLOCK: StreamFlags =3D (1 << 0); + #[derive(Debug)] pub struct Stream { ptr: Option, @@ -69,7 +79,17 @@ impl Drop for Stream { } =20 impl Stream { - pub fn new(ptr: sys::virStreamPtr) -> Stream { + pub fn new(conn: &Connect, flags: StreamFlags) -> Result { + unsafe { + let ptr =3D virStreamNew(conn.as_ptr(), flags as libc::c_uint); + if ptr.is_null() { + return Err(Error::new()); + } + return Ok(Stream::from_ptr(ptr)); + } + } + + pub fn from_ptr(ptr: sys::virStreamPtr) -> Stream { Stream { ptr: Some(ptr) } } =20 @@ -126,4 +146,23 @@ impl Stream { }; usize::try_from(ret).map_err(|_| Error::new()) } + + pub fn event_update_callback(&self, events: StreamEventType) -> Result= <(), Error> { + let ret =3D unsafe { + virStreamEventUpdateCallback(self.as_ptr(), events as libc::c_= int) + }; + if ret =3D=3D -1 { + return Err(Error::new()); + } + return Ok(()); + } + + pub fn event_remove_callback(&self) -> Result<(), Error> { + unsafe { + if virStreamEventRemoveCallback(self.as_ptr()) =3D=3D -1 { + return Err(Error::new()); + } + return Ok(()); + } + } } diff --git a/tests/stream.rs b/tests/stream.rs new file mode 100644 index 0000000..16531b3 --- /dev/null +++ b/tests/stream.rs @@ -0,0 +1,40 @@ +/* + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * . + * + * Sahid Orentino Ferdjaoui + */ + +extern crate virt; + +mod common; + +use virt::stream::Stream; +use virt::stream::VIR_STREAM_NONBLOCK; + +#[test] +fn test_create_blocking() { + let c =3D common::conn(); + let s =3D Stream::new(&c, 0).unwrap(); + drop(s); + common::close(c); +} + +#[test] +fn test_create_non_blocking() { + let c =3D common::conn(); + let s =3D Stream::new(&c, VIR_STREAM_NONBLOCK).unwrap(); + drop(s); + common::close(c); +} --=20 2.24.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 14:19:49 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 ARC-Seal: i=1; a=rsa-sha256; t=1573595127; cv=none; d=zoho.com; s=zohoarc; b=KA449g0j22eumqfAtfZaa0uGO3q13bTt5WVprpiUgUVztVYUA+0KxV0GguRTfdClEPeOR0700D8sjeJO0o9rafCdQlGnhOLOsb/w2GUo6/wY3UeBwl9Dvguc865o9AzevLGq9mcIxuMNJIpwQOIfmtX5Ih0WFwi2KPby/qP+Uqo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573595127; 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=Mgnn1iZxNt/J+4e7qbj311T7vIOl+pNV4w4XxXsHV14=; b=eYuvIN66IZr0B5soErOMcJwNblZhlQ8wRoxBsfw4GaUK3bJB/AEFkYVQ/XO8Qup521D6tGqn3jr0whEUSGiO5HxzwtO91TeMwxBaHud8cPzMWRftOteFppRaRWDc2SuVuqGDQdDKTHQTCZxaNDowpjVfL6H1PM78FRvhwajJWLo= 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 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 1573595127284859.6346076962651; Tue, 12 Nov 2019 13:45:27 -0800 (PST) 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-241-8AocmhrjM_uRGZrQ__Pd1Q-1; Tue, 12 Nov 2019 16:45:23 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2DEA8800A1E; Tue, 12 Nov 2019 21:45:15 +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 F39B34D713; Tue, 12 Nov 2019 21:45:14 +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 7C8BB4E567; Tue, 12 Nov 2019 21:45:14 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xACLitl5027036 for ; Tue, 12 Nov 2019 16:44:56 -0500 Received: by smtp.corp.redhat.com (Postfix) id D208010D16B8; Tue, 12 Nov 2019 21:44:55 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CD4D210D16AD for ; Tue, 12 Nov 2019 21:44:53 +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 B2D528E3866 for ; Tue, 12 Nov 2019 21:44:53 +0000 (UTC) Received: from balrog.mythic-beasts.com (balrog.mythic-beasts.com [46.235.227.24]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-208-FDF5fMukM96yeThXQhwgvw-1; Tue, 12 Nov 2019 16:44:51 -0500 Received: from [199.195.250.187] (port=45797 helo=hermes.aosc.io) by balrog.mythic-beasts.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92.3) (envelope-from ) id 1iUdxy-0008Ko-CR; Tue, 12 Nov 2019 21:44:50 +0000 Received: from liushuyu.lan (unknown [172.22.1.1]) by hermes.aosc.io (Postfix) with ESMTPS id E035241B78; Tue, 12 Nov 2019 21:44:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573595126; 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=Mgnn1iZxNt/J+4e7qbj311T7vIOl+pNV4w4XxXsHV14=; b=ClAfMrz8neXuq5195Wn3mao2kgzlwwG7asFrmRd0z5pUdaQJGcsuR07B4Ywgifq1kYoUrU ixfhk4oUSE2LaswVeLyJl5okw8gocVQX1JHYe2xL3ma1Pc2Lrinh2J4sBv+Pylwouszr7f uHRMIra+pvkrnYI5Qj6iLu5t8NEcnFI= From: Zixing Liu To: libvir-list@redhat.com Date: Tue, 12 Nov 2019 14:44:43 -0700 Message-Id: <20191112214445.14541-3-liushuyu@aosc.io> In-Reply-To: <20191112214445.14541-1-liushuyu@aosc.io> References: <20191112214445.14541-1-liushuyu@aosc.io> MIME-Version: 1.0 X-Spamd-Result: default: False [2.90 / 15.00] R_MISSING_CHARSET(2.50)[] BROKEN_CONTENT_TYPE(1.50)[] REPLY(-2.00)[] MID_CONTAINS_FROM(1.00)[] TO_DN_ALL(0.00)[] FROM_EQ_ENVFROM(0.00)[] MAILCOW_MOO(0.00)[] FROM_HAS_DN(0.00)[] TO_MATCH_ENVRCPT_ALL(0.00)[] RCPT_COUNT_THREE(0.00)[3] RCVD_COUNT_TWO(0.00)[2] MIME_GOOD(-0.10)[text/plain] X-Rspamd-Server: rspamd X-Rspamd-Scan-Time: 0.01 X-Rspamd-Queue-ID: E035241B78 X-BlackCat-Spam-Score: 50 X-Spam-Status: No, score=5.0 X-MC-Unique: FDF5fMukM96yeThXQhwgvw-1 X-MC-Unique: 8AocmhrjM_uRGZrQ__Pd1Q-1 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id xACLitl5027036 X-loop: libvir-list@redhat.com Cc: Zixing Liu , sahid.ferdjaoui@canonical.com Subject: [libvirt] [PATCH Rust 2/4] libvirt-rust: stream: add more functions in stream 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.16 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" * added virStreamEventAddCallback function * added new types: StreamEventCallback and FreeCallback * added new field: callback for storing event callback * drop: will drop the Box if any * added wrapper event_callback for easier callback authoring for the user (so that closures with Fn or FnMut references could be used) * added padding function event_free to just makes it compile (Rust should not need this, because Rust sticks to RAII) Signed-off-by: Zixing Liu --- src/stream.rs | 46 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/src/stream.rs b/src/stream.rs index de272ab..1ffd186 100644 --- a/src/stream.rs +++ b/src/stream.rs @@ -47,6 +47,12 @@ extern "C" { fn virStreamFree(c: sys::virStreamPtr) -> libc::c_int; fn virStreamAbort(c: sys::virStreamPtr) -> libc::c_int; fn virStreamFinish(c: sys::virStreamPtr) -> libc::c_int; + fn virStreamEventAddCallback(c: sys::virStreamPtr, + event: libc::c_int, + callback: StreamEventCallback, + opaque: *const libc::c_void, + ff: FreeCallback) + -> libc::c_int; fn virStreamEventUpdateCallback(c: sys::virStreamPtr, events: libc::c_int) -> libc::c_int; fn virStreamEventRemoveCallback(c: sys::virStreamPtr) -> libc::c_int; @@ -61,9 +67,26 @@ pub const VIR_STREAM_EVENT_HANGUP: StreamEventType =3D (= 1 << 3); pub type StreamFlags =3D self::libc::c_uint; pub const VIR_STREAM_NONBLOCK: StreamFlags =3D (1 << 0); =20 -#[derive(Debug)] +pub type StreamEventCallback =3D extern "C" fn(sys::virStreamPtr, libc::c_= int, *const libc::c_void); +pub type FreeCallback =3D extern "C" fn(*mut libc::c_void); + +// wrapper for callbacks +extern "C" fn event_callback(c: sys::virStreamPtr, flags: libc::c_int, opa= que: *const libc::c_void) { + let flags =3D flags as StreamFlags; + let shadow_self =3D unsafe { + &mut*(opaque as *mut Stream) + }; + if let Some(callback) =3D &mut shadow_self.callback { + callback(&Stream::from_ptr(c), flags); + } +} + +extern "C" fn event_free(_opaque: *mut libc::c_void) {} + +// #[derive(Debug)] pub struct Stream { ptr: Option, + callback: Option>, } =20 impl Drop for Stream { @@ -75,6 +98,13 @@ impl Drop for Stream { e.message) } } + if self.callback.is_some() { + if let Err(e) =3D self.event_remove_callback() { + panic!("Unable to remove event callback for Stream, code {= }, message: {}", + e.code, + e.message) + } + } } } =20 @@ -90,7 +120,7 @@ impl Stream { } =20 pub fn from_ptr(ptr: sys::virStreamPtr) -> Stream { - Stream { ptr: Some(ptr) } + Stream { ptr: Some(ptr), callback: None } } =20 pub fn as_ptr(&self) -> sys::virStreamPtr { @@ -147,6 +177,18 @@ impl Stream { usize::try_from(ret).map_err(|_| Error::new()) } =20 + pub fn event_add_callback(&mut self, events: StreamEventType, cb: F) -> Result<(), Error> { + let ret =3D unsafe { + let ptr =3D &*self as *const _ as *const _; + virStreamEventAddCallback(self.as_ptr(), events as libc::c_int= , event_callback, ptr, event_free) + }; + if ret =3D=3D -1 { + return Err(Error::new()); + } + self.callback =3D Some(Box::new(cb)); + return Ok(()); + } + pub fn event_update_callback(&self, events: StreamEventType) -> Result= <(), Error> { let ret =3D unsafe { virStreamEventUpdateCallback(self.as_ptr(), events as libc::c_= int) --=20 2.24.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 14:19:49 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 ARC-Seal: i=1; a=rsa-sha256; t=1573595109; cv=none; d=zoho.com; s=zohoarc; b=XxbPYzwBfVtn2uuCh37bf6Q6DhuyRsO6INe/xg3FPNTvpxJ5cPiT90nU30abCqGU7Sj42JAp3eDhJBl+cKxKrmrmH0lEs9UjkM3QDPZJ4xhvgrKuCc81Jdrc6o98lwQmMGZlaQJNiOIZ1HQneMfLfcT5TvN3s/6/fhtvZqvLScw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573595109; 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=P+iqLk98KU7/v7wnXvYiTXJ+DNGnApsyRXik2/j+KN4=; b=G3pR7aaEvUs5Ze8bzH8xDkr42Lzm4nHd0iKEr6IrM7eZfZJY8XZHF8/mEm9JuUTMmtWq7K4hGGnbY1ZDzdFQ2wGxX5XukwPV+GkgMU3o6yRdN02h4UOiMDLI/XsCSVabmJGyNztXS3VHwXuZKEWWasAb2JR1MUiarPUs3C3g0tM= 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 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 1573595109780509.1930283802866; Tue, 12 Nov 2019 13:45:09 -0800 (PST) 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-370-tXdlkrYNMJC-rN-UzrbEeQ-1; Tue, 12 Nov 2019 16:45:06 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7F54D107ACFA; Tue, 12 Nov 2019 21:45: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 50ADD60174; Tue, 12 Nov 2019 21:45: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 55D121803C37; Tue, 12 Nov 2019 21:45:00 +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 xACLiumU027050 for ; Tue, 12 Nov 2019 16:44:56 -0500 Received: by smtp.corp.redhat.com (Postfix) id 4E9171C5B9; Tue, 12 Nov 2019 21:44:56 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4A2FE17896 for ; Tue, 12 Nov 2019 21:44:56 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.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 2CE148E3866 for ; Tue, 12 Nov 2019 21:44:56 +0000 (UTC) Received: from haggis.mythic-beasts.com (haggis.mythic-beasts.com [46.235.224.141]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-273-JI56I47xMteLmmOqQJzO2Q-1; Tue, 12 Nov 2019 16:44:54 -0500 Received: from [199.195.250.187] (port=57655 helo=hermes.aosc.io) by haggis.mythic-beasts.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92.3) (envelope-from ) id 1iUdy0-0004WO-6k; Tue, 12 Nov 2019 21:44:52 +0000 Received: from liushuyu.lan (unknown [172.22.1.1]) by hermes.aosc.io (Postfix) with ESMTPS id B56DD41B36; Tue, 12 Nov 2019 21:44:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573595108; 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=P+iqLk98KU7/v7wnXvYiTXJ+DNGnApsyRXik2/j+KN4=; b=LVggIY/LuiE3r1is+FiVVCwhQLNmLmT+PrXMJ4U2licAebfE1jXNC+/AZljj7ynvve4zkz /lodav4Dpk8YlCH3iqdi6BwE2BrOQIJK83+NCvF5XtgKxyrZPDIKd5gNo75I2KjV3AdqLW Pb/MVcasomshaBT7zErHyo1IWpXzUIo= From: Zixing Liu To: libvir-list@redhat.com Date: Tue, 12 Nov 2019 14:44:44 -0700 Message-Id: <20191112214445.14541-4-liushuyu@aosc.io> In-Reply-To: <20191112214445.14541-1-liushuyu@aosc.io> References: <20191112214445.14541-1-liushuyu@aosc.io> MIME-Version: 1.0 X-Spamd-Result: default: False [2.90 / 15.00] R_MISSING_CHARSET(2.50)[] BROKEN_CONTENT_TYPE(1.50)[] REPLY(-2.00)[] MID_CONTAINS_FROM(1.00)[] TO_DN_ALL(0.00)[] FROM_EQ_ENVFROM(0.00)[] MAILCOW_MOO(0.00)[] FROM_HAS_DN(0.00)[] TO_MATCH_ENVRCPT_ALL(0.00)[] RCPT_COUNT_THREE(0.00)[3] RCVD_COUNT_TWO(0.00)[2] MIME_GOOD(-0.10)[text/plain] X-Rspamd-Server: rspamd X-Rspamd-Scan-Time: 0.01 X-Rspamd-Queue-ID: B56DD41B36 X-BlackCat-Spam-Score: 50 X-Spam-Status: No, score=5.0 X-MC-Unique: JI56I47xMteLmmOqQJzO2Q-1 X-MC-Unique: tXdlkrYNMJC-rN-UzrbEeQ-1 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 xACLiumU027050 X-loop: libvir-list@redhat.com Cc: Zixing Liu , sahid.ferdjaoui@canonical.com Subject: [libvirt] [PATCH Rust 3/4] libvirt-rust: stream: automated lint 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.11 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" * used rustfmt to clean up the code Signed-off-by: Zixing Liu --- src/stream.rs | 97 +++++++++++++++++++++++++++++---------------------- 1 file changed, 56 insertions(+), 41 deletions(-) diff --git a/src/stream.rs b/src/stream.rs index 1ffd186..0d84fd7 100644 --- a/src/stream.rs +++ b/src/stream.rs @@ -18,8 +18,8 @@ =20 extern crate libc; =20 -use connect::Connect; use connect::sys::virConnectPtr; +use connect::Connect; use std::convert::TryFrom; =20 use error::Error; @@ -33,28 +33,28 @@ pub mod sys { =20 #[link(name =3D "virt")] extern "C" { - fn virStreamNew(c: virConnectPtr, - flags: libc::c_uint) - -> sys::virStreamPtr; - fn virStreamSend(c: sys::virStreamPtr, - data: *const libc::c_char, - nbytes: libc::size_t) - -> libc::c_int; - fn virStreamRecv(c: sys::virStreamPtr, - data: *mut libc::c_char, - nbytes: libc::size_t) - -> libc::c_int; + fn virStreamNew(c: virConnectPtr, flags: libc::c_uint) -> sys::virStre= amPtr; + fn virStreamSend( + c: sys::virStreamPtr, + data: *const libc::c_char, + nbytes: libc::size_t, + ) -> libc::c_int; + fn virStreamRecv( + c: sys::virStreamPtr, + data: *mut libc::c_char, + nbytes: libc::size_t, + ) -> libc::c_int; fn virStreamFree(c: sys::virStreamPtr) -> libc::c_int; fn virStreamAbort(c: sys::virStreamPtr) -> libc::c_int; fn virStreamFinish(c: sys::virStreamPtr) -> libc::c_int; - fn virStreamEventAddCallback(c: sys::virStreamPtr, - event: libc::c_int, - callback: StreamEventCallback, - opaque: *const libc::c_void, - ff: FreeCallback) - -> libc::c_int; - fn virStreamEventUpdateCallback(c: sys::virStreamPtr, - events: libc::c_int) -> libc::c_int; + fn virStreamEventAddCallback( + c: sys::virStreamPtr, + event: libc::c_int, + callback: StreamEventCallback, + opaque: *const libc::c_void, + ff: FreeCallback, + ) -> libc::c_int; + fn virStreamEventUpdateCallback(c: sys::virStreamPtr, events: libc::c_= int) -> libc::c_int; fn virStreamEventRemoveCallback(c: sys::virStreamPtr) -> libc::c_int; } =20 @@ -71,14 +71,16 @@ pub type StreamEventCallback =3D extern "C" fn(sys::vir= StreamPtr, libc::c_int, *co pub type FreeCallback =3D extern "C" fn(*mut libc::c_void); =20 // wrapper for callbacks -extern "C" fn event_callback(c: sys::virStreamPtr, flags: libc::c_int, opa= que: *const libc::c_void) { - let flags =3D flags as StreamFlags; - let shadow_self =3D unsafe { - &mut*(opaque as *mut Stream) - }; - if let Some(callback) =3D &mut shadow_self.callback { - callback(&Stream::from_ptr(c), flags); - } +extern "C" fn event_callback( + c: sys::virStreamPtr, + flags: libc::c_int, + opaque: *const libc::c_void, +) { + let flags =3D flags as StreamFlags; + let shadow_self =3D unsafe { &mut *(opaque as *mut Stream) }; + if let Some(callback) =3D &mut shadow_self.callback { + callback(&Stream::from_ptr(c), flags); + } } =20 extern "C" fn event_free(_opaque: *mut libc::c_void) {} @@ -93,16 +95,18 @@ impl Drop for Stream { fn drop(&mut self) { if self.ptr.is_some() { if let Err(e) =3D self.free() { - panic!("Unable to drop memory for Stream, code {}, message= : {}", - e.code, - e.message) + panic!( + "Unable to drop memory for Stream, code {}, message: {= }", + e.code, e.message + ) } } if self.callback.is_some() { if let Err(e) =3D self.event_remove_callback() { - panic!("Unable to remove event callback for Stream, code {= }, message: {}", - e.code, - e.message) + panic!( + "Unable to remove event callback for Stream, code {}, = message: {}", + e.code, e.message + ) } } } @@ -120,7 +124,10 @@ impl Stream { } =20 pub fn from_ptr(ptr: sys::virStreamPtr) -> Stream { - Stream { ptr: Some(ptr), callback: None } + Stream { + ptr: Some(ptr), + callback: None, + } } =20 pub fn as_ptr(&self) -> sys::virStreamPtr { @@ -160,7 +167,7 @@ impl Stream { virStreamSend( self.as_ptr(), data.as_ptr() as *mut libc::c_char, - data.len() + data.len(), ) }; usize::try_from(ret).map_err(|_| Error::new()) @@ -177,10 +184,20 @@ impl Stream { usize::try_from(ret).map_err(|_| Error::new()) } =20 - pub fn event_add_callback(&mut self, events: StreamEventType, cb: F) -> Result<(), Error> { + pub fn event_add_callback( + &mut self, + events: StreamEventType, + cb: F, + ) -> Result<(), Error> { let ret =3D unsafe { let ptr =3D &*self as *const _ as *const _; - virStreamEventAddCallback(self.as_ptr(), events as libc::c_int= , event_callback, ptr, event_free) + virStreamEventAddCallback( + self.as_ptr(), + events as libc::c_int, + event_callback, + ptr, + event_free, + ) }; if ret =3D=3D -1 { return Err(Error::new()); @@ -190,9 +207,7 @@ impl Stream { } =20 pub fn event_update_callback(&self, events: StreamEventType) -> Result= <(), Error> { - let ret =3D unsafe { - virStreamEventUpdateCallback(self.as_ptr(), events as libc::c_= int) - }; + let ret =3D unsafe { virStreamEventUpdateCallback(self.as_ptr(), e= vents as libc::c_int) }; if ret =3D=3D -1 { return Err(Error::new()); } --=20 2.24.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 14:19:49 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 ARC-Seal: i=1; a=rsa-sha256; t=1573595109; cv=none; d=zoho.com; s=zohoarc; b=hgJxw4jUpMP0Rxh1i0BMVbpr6T4cEquY5TijysJU9FJn3r++ZVVIvK2ErZwWgK4f8pZ/Kmm9Q8ZnbyQ2iSBIqH3dw/4zl9uxEHLeykzHbhbjLayZspcqI30XtG5eFoBD81JvJ7jAllGS7PfpxvS9NZFc0GZe0okVQMUhECD/jXs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573595109; 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=NNa9rBdKrz3mzy8P5BxYHtfIBGJnQaySYfGYTzY0fZE=; b=bRMrWRVkehn/JjcFUuTPD+Qh6VYIblmL1y8Ua9bKc2/EYKFk84WHVpvI5vEeAYmqQ+/0fKaTSj5Kq4t6Ko6PyYiDppaQy3s6MU2NOH6K1bv1yXqNjdMLyMWW7FFJ2oxXzjNMG1QQdW+ynPSj89Tlz1jdowKki7daA9Vb/MsSxkU= 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 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 1573595109600246.60930102217424; Tue, 12 Nov 2019 13:45:09 -0800 (PST) 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-316-TQL7WhfFPCSEpqDSqYZBEg-1; Tue, 12 Nov 2019 16:45:06 -0500 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 2D17985B6FA; Tue, 12 Nov 2019 21:45:01 +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 D49853799; Tue, 12 Nov 2019 21:45:00 +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 D3D804BB65; Tue, 12 Nov 2019 21:44:57 +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 xACLitZk027031 for ; Tue, 12 Nov 2019 16:44:55 -0500 Received: by smtp.corp.redhat.com (Postfix) id BDB621C5B9; Tue, 12 Nov 2019 21:44:55 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B9AF2178BB for ; Tue, 12 Nov 2019 21:44:55 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) (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 A2458800296 for ; Tue, 12 Nov 2019 21:44:55 +0000 (UTC) Received: from balrog.mythic-beasts.com (balrog.mythic-beasts.com [46.235.227.24]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-34-eICq7ckbOqS1xkg5rKQpjQ-1; Tue, 12 Nov 2019 16:44:53 -0500 Received: from [199.195.250.187] (port=45810 helo=hermes.aosc.io) by balrog.mythic-beasts.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92.3) (envelope-from ) id 1iUdy0-00004u-10; Tue, 12 Nov 2019 21:44:52 +0000 Received: from liushuyu.lan (unknown [172.22.1.1]) by hermes.aosc.io (Postfix) with ESMTPS id 918C941B79; Tue, 12 Nov 2019 21:44:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573595108; 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=NNa9rBdKrz3mzy8P5BxYHtfIBGJnQaySYfGYTzY0fZE=; b=gA2FCu7X+fhxc4yYjw5koeHaYHtptD0mIZhpgKczlkncPx+4OVa9KE7+PiZPF2st+Q6Nzu VH87Z1DEDIq4hiwWrAloR2RITtTptJxQRnX4frFTJvoDacKHN9gjQJw5TAsU9zqwb/XX2H NJXnFeApR6O9wvskYaxD/rev5zXFZ7U= From: Zixing Liu To: libvir-list@redhat.com Date: Tue, 12 Nov 2019 14:44:45 -0700 Message-Id: <20191112214445.14541-5-liushuyu@aosc.io> In-Reply-To: <20191112214445.14541-1-liushuyu@aosc.io> References: <20191112214445.14541-1-liushuyu@aosc.io> MIME-Version: 1.0 X-Spamd-Result: default: False [2.90 / 15.00] BROKEN_CONTENT_TYPE(1.50)[] REPLY(-2.00)[] R_MISSING_CHARSET(2.50)[] MID_CONTAINS_FROM(1.00)[] TO_DN_ALL(0.00)[] BAYES_SPAM(0.00)[27.91%] FROM_EQ_ENVFROM(0.00)[] MAILCOW_MOO(0.00)[] FROM_HAS_DN(0.00)[] TO_MATCH_ENVRCPT_ALL(0.00)[] RCPT_COUNT_THREE(0.00)[3] RCVD_COUNT_TWO(0.00)[2] MIME_GOOD(-0.10)[text/plain] X-Rspamd-Server: rspamd X-Rspamd-Scan-Time: 0.01 X-Rspamd-Queue-ID: 918C941B79 X-BlackCat-Spam-Score: 50 X-Spam-Status: No, score=5.0 X-MC-Unique: eICq7ckbOqS1xkg5rKQpjQ-1 X-MC-Unique: TQL7WhfFPCSEpqDSqYZBEg-1 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 xACLitZk027031 X-loop: libvir-list@redhat.com Cc: Zixing Liu , sahid.ferdjaoui@canonical.com Subject: [libvirt] [PATCH Rust 4/4] libvirt-rust: use reference instead of moving 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-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Zixing Liu Reviewed-by: Sahid Orentino Ferdjaoui --- src/domain.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/domain.rs b/src/domain.rs index acb9e6e..4d4f593 100644 --- a/src/domain.rs +++ b/src/domain.rs @@ -1397,7 +1397,7 @@ impl Domain { } } =20 - pub fn open_console(&self, name: &str, stream: Stream, flags: u32) -> = Result { + pub fn open_console(&self, name: &str, stream: &Stream, flags: u32) ->= Result { unsafe { let ret =3D virDomainOpenConsole(self.as_ptr(), string_to_c_chars!(name), --=20 2.24.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list