<div dir="ltr">Dear Richard,<div><br></div><div>> Normally we wouldn't check generated files into git.</div><div><br></div><div>OK. I got it.</div><div><br></div><div>Regards,<br></div><div>Hiroyuki</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">2019年6月27日(木) 18:51 Richard W.M. Jones <<a href="mailto:rjones@redhat.com">rjones@redhat.com</a>>:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Thu, Jun 27, 2019 at 06:27:05PM +0900, Hiroyuki Katsura wrote:<br>
> > I guess this is a stray debug message?<br>
> <br>
> Yes. I'm sorry...<br>
> <br>
> > we did *not* check them into git.<br>
> <br>
> Really? Does it mean that every time you build the library, Cargo.toml is<br>
> generated?<br>
<br>
That's how it has worked in nbdkit.  Whether it's right or not I don't<br>
know.  Normally we wouldn't check generated files into git.<br>
<br>
> > The actual test parts of this patch are fine, but you need to spend a<br>
> > bit of time with ‘git rebase -i’ to move parts of patch 3 into patch 2.<br>
> <br>
> Does this mean that the followings should be moved to patch 2?<br>
> <br>
>  generator/<a href="http://rust.ml" rel="noreferrer" target="_blank">rust.ml</a>                 | 13 ++++++++---<br>
>  <a href="http://run.in" rel="noreferrer" target="_blank">run.in</a>                            |  9 ++++++++<br>
>  rust/Cargo.lock                   |  6 +++++<br>
>  rust/Cargo.toml                   |  4 +---<br>
<br>
I think so, except maybe the Cargo.* files might not be included at<br>
all - see above.<br>
<br>
Rich.<br>
<br>
> Regards,<br>
> Hiroyuki<br>
> <br>
> <br>
> 2019年6月27日(木) 17:52 Richard W.M. Jones <<a href="mailto:rjones@redhat.com" target="_blank">rjones@redhat.com</a>>:<br>
> <br>
> > On Thu, Jun 27, 2019 at 05:06:04PM +0900, Hiroyuki Katsura wrote:<br>
> > > From: Hiroyuki_Katsura <<a href="mailto:hiroyuki.katsura.0513@gmail.com" target="_blank">hiroyuki.katsura.0513@gmail.com</a>><br>
> > ><br>
> > > ---<br>
> > >  generator/<a href="http://rust.ml" rel="noreferrer" target="_blank">rust.ml</a>                 | 13 ++++++++---<br>
> > >  <a href="http://run.in" rel="noreferrer" target="_blank">run.in</a>                            |  9 ++++++++<br>
> > >  rust/Cargo.lock                   |  6 +++++<br>
> > >  rust/Cargo.toml                   |  4 +---<br>
> > >  rust/tests/<a href="http://010_load.rs" rel="noreferrer" target="_blank">010_load.rs</a>            | 24 +++++++++++++++++++<br>
> > >  rust/tests/<a href="http://020_create.rs" rel="noreferrer" target="_blank">020_create.rs</a>          | 24 +++++++++++++++++++<br>
> > >  rust/tests/<a href="http://030_create_flags.rs" rel="noreferrer" target="_blank">030_create_flags.rs</a>    | 30 ++++++++++++++++++++++++<br>
> > >  rust/tests/<a href="http://040_create_multiple.rs" rel="noreferrer" target="_blank">040_create_multiple.rs</a> | 38 +++++++++++++++++++++++++++++++<br>
> > >  8 files changed, 142 insertions(+), 6 deletions(-)<br>
> > >  create mode 100644 rust/Cargo.lock<br>
> > >  create mode 100644 rust/tests/<a href="http://010_load.rs" rel="noreferrer" target="_blank">010_load.rs</a><br>
> > >  create mode 100644 rust/tests/<a href="http://020_create.rs" rel="noreferrer" target="_blank">020_create.rs</a><br>
> > >  create mode 100644 rust/tests/<a href="http://030_create_flags.rs" rel="noreferrer" target="_blank">030_create_flags.rs</a><br>
> > >  create mode 100644 rust/tests/<a href="http://040_create_multiple.rs" rel="noreferrer" target="_blank">040_create_multiple.rs</a><br>
> > ><br>
> > > diff --git a/generator/<a href="http://rust.ml" rel="noreferrer" target="_blank">rust.ml</a> b/generator/<a href="http://rust.ml" rel="noreferrer" target="_blank">rust.ml</a><br>
> > > index dbe9db010..251eb1594 100644<br>
> > > --- a/generator/<a href="http://rust.ml" rel="noreferrer" target="_blank">rust.ml</a><br>
> > > +++ b/generator/<a href="http://rust.ml" rel="noreferrer" target="_blank">rust.ml</a><br>
> > > @@ -37,14 +37,16 @@ let generate_rust () =<br>
> > >  #[allow(non_camel_case_types)]<br>
> > >  enum guestfs_h {}<br>
> > ><br>
> > > +#[link(name = \"guestfs\")]<br>
> > >  extern \"C\" {<br>
> > >      fn guestfs_create() -> *mut guestfs_h;<br>
> > >      fn guestfs_create_flags(flags: i64) -> *mut guestfs_h;<br>
> > >      fn guestfs_close(g: *mut guestfs_h);<br>
> > > -    static GUESTFS_CREATE_NO_ENVIRONMENT: i64;<br>
> > > -    static GUESTFS_CREATE_NO_CLOSE_ON_EXIT: i64;<br>
> > >  }<br>
> > ><br>
> > > +const GUESTFS_CREATE_NO_ENVIRONMENT: i64 = 1;<br>
> > > +const GUESTFS_CREATE_NO_CLOSE_ON_EXIT: i64 = 2;<br>
> > > +<br>
> > >  pub struct Handle {<br>
> > >      g: *mut guestfs_h,<br>
> > >  }<br>
> > > @@ -61,13 +63,17 @@ pub struct CreateFlags {<br>
> > >  }<br>
> > ><br>
> > >  impl CreateFlags {<br>
> > > -    pub fn new() -> CreateFlags {<br>
> > > +    pub fn none() -> CreateFlags {<br>
> > >          CreateFlags {<br>
> > >              create_no_environment_flag: false,<br>
> > >              create_no_close_on_exit_flag: false,<br>
> > >          }<br>
> > >      }<br>
> > ><br>
> > > +    pub fn new() -> CreateFlags {<br>
> > > +        CreateFlags::none()<br>
> > > +    }<br>
> > > +<br>
> > >      pub fn create_no_environment(mut self, flag: bool) -> CreateFlags {<br>
> > >          self.create_no_environment_flag = flag;<br>
> > >          self<br>
> ><br>
> > Shouldn't these changes be folded into patch 2?<br>
> ><br>
> > > @@ -97,6 +103,7 @@ impl CreateFlags {<br>
> > >  impl Handle {<br>
> > >      pub fn create() -> Result<Handle, &'static str> {<br>
> > >          let g = unsafe { guestfs_create() };<br>
> > > +        println!(\"hoge\");<br>
> ><br>
> > I guess this is a stray debug message?<br>
> ><br>
> > >          if g.is_null() {<br>
> > >              Err(\"failed to create guestfs handle\")<br>
> > >          } else {<br>
> > > diff --git a/<a href="http://run.in" rel="noreferrer" target="_blank">run.in</a> b/<a href="http://run.in" rel="noreferrer" target="_blank">run.in</a><br>
> > > index 488e1b937..301b02664 100755<br>
> > > --- a/<a href="http://run.in" rel="noreferrer" target="_blank">run.in</a><br>
> > > +++ b/<a href="http://run.in" rel="noreferrer" target="_blank">run.in</a><br>
> > > @@ -201,6 +201,15 @@ else<br>
> > >  fi<br>
> > >  export CGO_LDFLAGS<br>
> > ><br>
> > > +# For rust<br>
> > > +export RUST="@RUST@"<br>
> > > +if [ -z "$RUSTFLAGS" ]; then<br>
> > > +    RUSTFLAGS="-C link-args=-L$b/lib/.libs"<br>
> > > +else<br>
> > > +    RUSTFLAGS="$RUSTFLAGS -C link-args=-L$b/lib/.libs"<br>
> > > +fi<br>
> > > +export RUSTFLAGS<br>
> > > +<br>
> > >  # For GObject, Javascript and friends.<br>
> > >  export GJS="@GJS@"<br>
> > >  prepend GI_TYPELIB_PATH "$b/gobject"<br>
> > > diff --git a/rust/Cargo.lock b/rust/Cargo.lock<br>
> > > new file mode 100644<br>
> > > index 000000000..c03586e3f<br>
> > > --- /dev/null<br>
> > > +++ b/rust/Cargo.lock<br>
> > > @@ -0,0 +1,6 @@<br>
> > > +# This file is automatically @generated by Cargo.<br>
> > > +# It is not intended for manual editing.<br>
> > > +[[package]]<br>
> > > +name = "guestfs"<br>
> > > +version = "0.1.0"<br>
> > > +<br>
> > > diff --git a/rust/Cargo.toml b/rust/Cargo.toml<br>
> > > index 6cd94ce6a..4ea7c299b 100644<br>
> > > --- a/rust/Cargo.toml<br>
> > > +++ b/rust/Cargo.toml<br>
> > > @@ -1,8 +1,6 @@<br>
> > >  [package]<br>
> > > -name = "rust"<br>
> > > +name = "guestfs"<br>
> > >  version = "0.1.0"<br>
> > >  edition = "2018"<br>
> > ><br>
> > >  [dependencies]<br>
> > > -libc = "0.2"<br>
> > > -<br>
> ><br>
> > In nbdkit we added Cargo.lock and Cargo.toml to .gitignore and<br>
> > we did *not* check them into git.<br>
> ><br>
> > > diff --git a/rust/tests/<a href="http://010_load.rs" rel="noreferrer" target="_blank">010_load.rs</a> b/rust/tests/<a href="http://010_load.rs" rel="noreferrer" target="_blank">010_load.rs</a><br>
> > > new file mode 100644<br>
> > > index 000000000..eadd78896<br>
> > > --- /dev/null<br>
> > > +++ b/rust/tests/<a href="http://010_load.rs" rel="noreferrer" target="_blank">010_load.rs</a><br>
> > > @@ -0,0 +1,24 @@<br>
> > > +/* libguestfs Python bindings<br>
> > > + Copyright (C) 2009-2019 Red Hat Inc.<br>
> > > +<br>
> > > + This program is free software; you can redistribute it and/or modify<br>
> > > + it under the terms of the GNU General Public License as published by<br>
> > > + the Free Software Foundation; either version 2 of the License, or<br>
> > > + (at your option) any later version.<br>
> > > +<br>
> > > + This program is distributed in the hope that it will be useful,<br>
> > > + but WITHOUT ANY WARRANTY; without even the implied warranty of<br>
> > > + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the<br>
> > > + GNU General Public License for more details.<br>
> > > +<br>
> > > + You should have received a copy of the GNU General Public License<br>
> > > + along with this program; if not, write to the Free Software<br>
> > > + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA<br>
> > 02110-1301 USA.<br>
> > > + */<br>
> > > +<br>
> > > +extern crate guestfs;<br>
> > > +<br>
> > > +#[test]<br>
> > > +fn load() {<br>
> > > +    // nop<br>
> > > +}<br>
> > > diff --git a/rust/tests/<a href="http://020_create.rs" rel="noreferrer" target="_blank">020_create.rs</a> b/rust/tests/<a href="http://020_create.rs" rel="noreferrer" target="_blank">020_create.rs</a><br>
> > > new file mode 100644<br>
> > > index 000000000..0b57b19d7<br>
> > > --- /dev/null<br>
> > > +++ b/rust/tests/<a href="http://020_create.rs" rel="noreferrer" target="_blank">020_create.rs</a><br>
> > > @@ -0,0 +1,24 @@<br>
> > > +/* libguestfs Python bindings<br>
> > > + Copyright (C) 2009-2019 Red Hat Inc.<br>
> > > +<br>
> > > + This program is free software; you can redistribute it and/or modify<br>
> > > + it under the terms of the GNU General Public License as published by<br>
> > > + the Free Software Foundation; either version 2 of the License, or<br>
> > > + (at your option) any later version.<br>
> > > +<br>
> > > + This program is distributed in the hope that it will be useful,<br>
> > > + but WITHOUT ANY WARRANTY; without even the implied warranty of<br>
> > > + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the<br>
> > > + GNU General Public License for more details.<br>
> > > +<br>
> > > + You should have received a copy of the GNU General Public License<br>
> > > + along with this program; if not, write to the Free Software<br>
> > > + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA<br>
> > 02110-1301 USA.<br>
> > > + */<br>
> > > +<br>
> > > +extern crate guestfs;<br>
> > > +<br>
> > > +#[test]<br>
> > > +fn create() {<br>
> > > +    assert!(!guestfs::Handle::create().is_err(), "create fail");<br>
> > > +}<br>
> > > diff --git a/rust/tests/<a href="http://030_create_flags.rs" rel="noreferrer" target="_blank">030_create_flags.rs</a> b/rust/tests/<br>
> > <a href="http://030_create_flags.rs" rel="noreferrer" target="_blank">030_create_flags.rs</a><br>
> > > new file mode 100644<br>
> > > index 000000000..5de0589c1<br>
> > > --- /dev/null<br>
> > > +++ b/rust/tests/<a href="http://030_create_flags.rs" rel="noreferrer" target="_blank">030_create_flags.rs</a><br>
> > > @@ -0,0 +1,30 @@<br>
> > > +/* libguestfs Python bindings<br>
> > > + Copyright (C) 2009-2019 Red Hat Inc.<br>
> > > +<br>
> > > + This program is free software; you can redistribute it and/or modify<br>
> > > + it under the terms of the GNU General Public License as published by<br>
> > the Free Software Foundation; either version 2 of the License, or<br>
> > > + (at your option) any later version.<br>
> > > +<br>
> > > + This program is distributed in the hope that it will be useful,<br>
> > > + but WITHOUT ANY WARRANTY; without even the implied warranty of<br>
> > > + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the<br>
> > > + GNU General Public License for more details.<br>
> > > +<br>
> > > + You should have received a copy of the GNU General Public License<br>
> > > + along with this program; if not, write to the Free Software<br>
> > > + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA<br>
> > 02110-1301 USA.<br>
> > > + */<br>
> > > +<br>
> > > +extern crate guestfs;<br>
> > > +<br>
> > > +use guestfs::*;<br>
> > > +<br>
> > > +#[test]<br>
> > > +fn create_flags() {<br>
> > > +    let _h =<br>
> > Handle::create_flags(CreateFlags::none()).expect("create_flags fail");<br>
> > > +    // TODO: Add parse_environment to check the flag is created<br>
> > correctly<br>
> > > +    let flags = CreateFlags::new()<br>
> > > +        .create_no_environment(true);<br>
> > > +    let _h = Handle::create_flags(flags).expect("create_flags fail");<br>
> > > +    // TODO: Add parse_environment to check the flag is created<br>
> > correctly<br>
> > > +}<br>
> > > diff --git a/rust/tests/<a href="http://040_create_multiple.rs" rel="noreferrer" target="_blank">040_create_multiple.rs</a> b/rust/tests/<br>
> > <a href="http://040_create_multiple.rs" rel="noreferrer" target="_blank">040_create_multiple.rs</a><br>
> > > new file mode 100644<br>
> > > index 000000000..ee481c278<br>
> > > --- /dev/null<br>
> > > +++ b/rust/tests/<a href="http://040_create_multiple.rs" rel="noreferrer" target="_blank">040_create_multiple.rs</a><br>
> > > @@ -0,0 +1,38 @@<br>
> > > +/* libguestfs Python bindings<br>
> > > + Copyright (C) 2009-2019 Red Hat Inc.<br>
> > > +<br>
> > > + This program is free software; you can redistribute it and/or modify<br>
> > > + it under the terms of the GNU General Public License as published by<br>
> > > + the Free Software Foundation; either version 2 of the License, or<br>
> > > + (at your option) any later version.<br>
> > > +<br>
> > > + This program is distributed in the hope that it will be useful,<br>
> > > + but WITHOUT ANY WARRANTY; without even the implied warranty of<br>
> > > + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the<br>
> > > + GNU General Public License for more details.<br>
> > > +<br>
> > > + You should have received a copy of the GNU General Public License<br>
> > > + along with this program; if not, write to the Free Software<br>
> > > + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA<br>
> > 02110-1301 USA.<br>
> > > + */<br>
> > > +<br>
> > > +extern crate guestfs;<br>
> > > +<br>
> > > +fn create() -> guestfs::Handle {<br>
> > > +    match guestfs::Handle::create() {<br>
> > > +        Ok(g) => g,<br>
> > > +        Err(e) => panic!("fail: {}", e),<br>
> > > +    }<br>
> > > +}<br>
> > > +<br>
> > > +fn ignore(_x: guestfs::Handle, _y: guestfs::Handle, _z:<br>
> > guestfs::Handle) {<br>
> > > +    // drop<br>
> > > +}<br>
> > > +<br>
> > > +#[test]<br>
> > > +fn create_multiple() {<br>
> > > +    let x = create();<br>
> > > +    let y = create();<br>
> > > +    let z = create();<br>
> > > +    ignore(x, y, z)<br>
> > > +}<br>
> > > --<br>
> > > 2.20.1 (Apple Git-117)<br>
> ><br>
> > The actual test parts of this patch are fine, but you need to spend a<br>
> > bit of time with ‘git rebase -i’ to move parts of patch 3 into patch 2.<br>
> ><br>
> > Rich.<br>
> ><br>
> > --<br>
> > Richard Jones, Virtualization Group, Red Hat<br>
> > <a href="http://people.redhat.com/~rjones" rel="noreferrer" target="_blank">http://people.redhat.com/~rjones</a><br>
> > Read my programming and virtualization blog: <a href="http://rwmj.wordpress.com" rel="noreferrer" target="_blank">http://rwmj.wordpress.com</a><br>
> > virt-df lists disk usage of guests without needing to install any<br>
> > software inside the virtual machine.  Supports Linux and Windows.<br>
> > <a href="http://people.redhat.com/~rjones/virt-df/" rel="noreferrer" target="_blank">http://people.redhat.com/~rjones/virt-df/</a><br>
> ><br>
<br>
-- <br>
Richard Jones, Virtualization Group, Red Hat <a href="http://people.redhat.com/~rjones" rel="noreferrer" target="_blank">http://people.redhat.com/~rjones</a><br>
Read my programming and virtualization blog: <a href="http://rwmj.wordpress.com" rel="noreferrer" target="_blank">http://rwmj.wordpress.com</a><br>
virt-df lists disk usage of guests without needing to install any<br>
software inside the virtual machine.  Supports Linux and Windows.<br>
<a href="http://people.redhat.com/~rjones/virt-df/" rel="noreferrer" target="_blank">http://people.redhat.com/~rjones/virt-df/</a><br>
</blockquote></div>