[pve-devel] SPAM: [PATCH v2 qemu-server 0/3] vmstatus: add pressure + hostcpu/hostmem

2021-02-17 Thread Alexandre Derumier
This add new cgroups value stats.

hostcpu/hostmem give the real cpu/mem usage of a vm, including vhost-net.


Changelog v2: 
 - rebase on last master
 - use new pressure code from pve-common


Alexandre Derumier (3):
  vmstatus: add hostcpu value
  vmstatus: add hostmem value
  vmstatus: add pressure stats

 PVE/QemuServer.pm | 18 ++
 1 file changed, 18 insertions(+)

-- 
2.20.1


___
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel



[pve-devel] SPAM: [PATCH v2 qemu-server 3/3] vmstatus: add pressure stats

2021-02-17 Thread Alexandre Derumier
Signed-off-by: Alexandre Derumier 
---
 PVE/QemuServer.pm | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 3a623c5..f99f969 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -2706,6 +2706,8 @@ sub vmstatus {
$d->{cpu} = $old->{cpu};
$d->{hostcpu} = $old->{hostcpu};
}
+
+   $d->{pressure} = $cgroups->get_pressure_stat();
 }
 
 return $res if !$full;
-- 
2.20.1


___
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel



[pve-devel] SPAM: [PATCH v2 pve-container 1/1] vmstatus: add pressure stats

2021-02-17 Thread Alexandre Derumier
Signed-off-by: Alexandre Derumier 
---
 src/PVE/LXC.pm | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm
index bae236b..be71ef1 100644
--- a/src/PVE/LXC.pm
+++ b/src/PVE/LXC.pm
@@ -297,6 +297,8 @@ sub vmstatus {
} else {
$d->{cpu} = 0;
}
+
+   $d->{pressure} = $cgroups->get_pressure_stat();
 }
 
 my $netdev = PVE::ProcFSTools::read_proc_net_dev();
-- 
2.20.1


___
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel



[pve-devel] [PATCH v2 qemu-server 1/3] vmstatus: add hostcpu value

2021-02-17 Thread Alexandre Derumier
Signed-off-by: Alexandre Derumier 
---
 PVE/QemuServer.pm | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index f401baf..52db3d3 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -2657,8 +2657,11 @@ sub vmstatus {
 
my $pstat = PVE::ProcFSTools::read_proc_pid_stat($pid);
next if !$pstat; # not running
+   my $cgroups = PVE::QemuServer::CGroup->new($vmid);
+   my $hostcpustat = $cgroups->get_cpu_stat();
 
my $used = $pstat->{utime} + $pstat->{stime};
+   my $hostused = $hostcpustat->{utime} + $hostcpustat->{stime};
 
$d->{uptime} = int(($uptime - $pstat->{starttime})/$cpuinfo->{user_hz});
 
@@ -2672,6 +2675,9 @@ sub vmstatus {
time => $ctime,
used => $used,
cpu => 0,
+   hostused => $hostused,
+   hostcpu => 0,
+
};
next;
}
@@ -2680,15 +2686,20 @@ sub vmstatus {
 
if ($dtime > 1000) {
my $dutime = $used -  $old->{used};
+   my $dhostutime = $hostused -  $old->{hostused};
 
$d->{cpu} = (($dutime/$dtime)* $cpucount) / $d->{cpus};
+   $d->{hostcpu} = (($dhostutime/$dtime)* $cpucount) / $d->{cpus};
$last_proc_pid_stat->{$pid} = {
time => $ctime,
used => $used,
cpu => $d->{cpu},
+   hostused => $hostused,
+   hostcpu => $d->{hostcpu},
};
} else {
$d->{cpu} = $old->{cpu};
+   $d->{hostcpu} = $old->{hostcpu};
}
 }
 
-- 
2.20.1


___
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel



[pve-devel] SPAM: [PATCH v2 pve-container 0/1] vmstatus: add pressure stats

2021-02-17 Thread Alexandre Derumier
changelog v2:

- rebase on last master
- use new pressure code from pve-common

Alexandre Derumier (1):
  vmstatus: add pressure stats

 src/PVE/LXC.pm | 2 ++
 1 file changed, 2 insertions(+)

-- 
2.20.1


___
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel



[pve-devel] [PATCH v2 qemu-server 2/3] vmstatus: add hostmem value

2021-02-17 Thread Alexandre Derumier
Signed-off-by: Alexandre Derumier 
---
 PVE/QemuServer.pm | 5 +
 1 file changed, 5 insertions(+)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 52db3d3..3a623c5 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -2668,6 +2668,11 @@ sub vmstatus {
if ($pstat->{vsize}) {
$d->{mem} = int(($pstat->{rss}/$pstat->{vsize})*$d->{maxmem});
}
+   if (defined(my $hostmemstat = $cgroups->get_memory_stat())) {
+   $d->{hostmem} = $hostmemstat->{mem};
+   } else {
+   $d->{hostmem} = 0;
+   }
 
my $old = $last_proc_pid_stat->{$pid};
if (!$old) {
-- 
2.20.1


___
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel



Re: [pve-devel] [PATCH V2 qemu-server] fix #1739: cloudinit: add cisshdeletehostkeys option

2021-02-17 Thread Mira Limbeck

Thank you for the patch.

I tried to test this patch with both a CentOS 8 and Ubuntu 20.04 VM and 
it never worked right.


I added another line for 'once|yes|on|true' where ssh_deletekeys is set 
to 'true' as that is missing in this patch. Then I tried it with CentOS 
8 and cloud-init 19.4.


In the beginning the keys were deleted and regenerated, but after a few 
tries no matter using either of 'once', 'yes', 'on' or 'true' did not 
change anything. Even with a new instance-id the keys were never deleted 
no regenerated.


In Ubuntu 20.04 with cloud-init 20.4 it was the other way around, even 
rebooting without any changes to the cloud-init config (no instance-id 
change) and cisshdeletehostkeys set to 'no' the keys were regenerated 
every time.


What did you use to test this patch (OS, cloud-init version, specific 
cloudimg)?



Some additional comments inline

On 2/7/21 3:18 PM, Alexandre Derumier wrote:

This define behaviour of ssh server keys generation on cloudinit
config change.

different value:

- once : only once at vmstart  (default value)
- no|off|false : never generate ssh key
- yes|on|true: always generate ssh key

When value is defined to 'once', the value is rewriten to 'no'
in vmconfig after vm start

We need to change instance-id at each config change because
network configuration is only done once in pre-init local service,
and a lock is done on instance-id, and they are no way to change
that in cloudinit vm config.

The ssh host keys are regenerated by ssh module, once by instance.
user could change that,and do only once,
but in this same ssh module, the user public keys are also deployed.

Signed-off-by: Alexandre Derumier 
---
  PVE/QemuServer.pm   |  9 -
  PVE/QemuServer/Cloudinit.pm | 10 +-
  2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index f401baf..c899b35 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -760,6 +760,13 @@ my $confdesc_cloudinit = {
format => 'urlencoded',
description => "cloud-init: Setup public SSH keys (one key per line, OpenSSH 
format).",
  },
+cisshdeletehostkeys => {
+   optional => 1,
+   type => 'string',
+   enum => [qw(once yes no on off true false)],
+   default_key => 1,
+   description => "cloud-init: Regenerate host SSH keys on config change.",
+},
  };


As mentioned on the previous patch, I'm not sure if we want to add 
another cloud-init config to the global config namespace. We could reuse 
the option 'cicustom' for this.


Perhaps @Thomas could chime in regarding this?

  
  # what about other qemu settings ?

@@ -4951,7 +4958,7 @@ sub vm_start_nolock {
$conf = PVE::QemuConfig->load_config($vmid); # update/reload
  }
  
-PVE::QemuServer::Cloudinit::generate_cloudinitconfig($conf, $vmid);

+PVE::QemuServer::Cloudinit::generate_cloudinitconfig($conf, $vmid, 1);
  
  my $defaults = load_defaults();
  
diff --git a/PVE/QemuServer/Cloudinit.pm b/PVE/QemuServer/Cloudinit.pm

index c464bf3..7b24f93 100644
--- a/PVE/QemuServer/Cloudinit.pm
+++ b/PVE/QemuServer/Cloudinit.pm
@@ -135,6 +135,7 @@ sub cloudinit_userdata {
foreach my $k (@$keys) {
$content .= "  - $k\n";
}
+   $content .= "ssh_deletekeys: false\n" if defined($conf->{cisshdeletehostkeys}) 
&& $conf->{cisshdeletehostkeys} =~ m/^(off|no|false)/;


This is missing the case for 'once', 'on', 'true' and 'yes' where 
ssh_deletekeys is set to 'true'.


And there's an additional whitespace at the end of the line.

  
  }

  $content .= "chpasswd:\n";
  $content .= "  expire: False\n";
@@ -554,9 +555,10 @@ my $cloudinit_methods = {
  };
  
  sub generate_cloudinitconfig {

-my ($conf, $vmid) = @_;
+my ($conf, $vmid, $vmstart) = @_;
  
  my $format = get_cloudinit_format($conf);

+my $generated = undef;
  
  PVE::QemuConfig->foreach_volume($conf, sub {

  my ($ds, $drive) = @_;
@@ -569,7 +571,13 @@ sub generate_cloudinitconfig {
or die "missing cloudinit methods for format '$format'\n";
  
  	$generator->($conf, $vmid, $drive, $volname, $storeid);

+   $generated = 1;
  });
+
+if ($vmstart && $generated && (!defined($conf->{cisshdeletehostkeys}) || 
$conf->{cisshdeletehostkeys} eq 'once')) {
+   $conf->{cisshdeletehostkeys} = 'no';
+   PVE::QemuConfig->write_config($vmid, $conf);
+}


This always sets 'cisshdeletehostkeys' to 'no' if it is not set at all 
in the config which changes the default. I'd rather not do that for all, 
but only if it is set explicitly to 'once'.


So that would then be:

if ($vmstart && $generated && defined($conf->{cisshdeletehostkeys}) && 
$conf->{cisshdeletehostkeys} eq 'once')



  }
  
  sub dump_cloudinit_config {



___
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel



[pve-devel] [PATCH common] format: fix render_bytes with CLIFormatter

2021-02-17 Thread Stefan Reiter
CLIFormatter passes in an options hash as a second paramter, which so
far was ignored. Now that we treat it as a precision parameter, check if
it is a hash and extract the option from it before using it.

Otherwise perl puts HASH(0x...) into the format and sprintf chokes.

Signed-off-by: Stefan Reiter 
---

Reported here: https://forum.proxmox.com/threads/bug-found-where-to-post.84407/

I'm getting too used to Rust...

 src/PVE/Format.pm | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/PVE/Format.pm b/src/PVE/Format.pm
index ed86029..366bc16 100644
--- a/src/PVE/Format.pm
+++ b/src/PVE/Format.pm
@@ -64,6 +64,8 @@ sub render_fraction_as_percentage {
 sub render_bytes {
 my ($value, $precision) = @_;
 
+$precision = $precision->{precision} if ref($precision) eq 'HASH';
+
 my @units = qw(B KiB MiB GiB TiB PiB);
 
 my $max_unit = 0;
-- 
2.20.1



___
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel



Re: [pve-devel] [PATCH-SERIES v2] loosen up mailto regex for backwards compatibility

2021-02-17 Thread Fabian Ebner

On 17.02.21 11:35, Fabian Ebner wrote:

On 17.02.21 10:52, Dominik Csapak wrote:

LGTM, nothing obvious that is wrong
one small thing though, after this patch i cannot
have an @ in the local part of an email anymore, though
i do not think that people actually use that?

e.g. foo@b...@example.com does not work anymore



Thanks for the review and for catching that! I'll send a follow-up (or 
does this warrant a v3?) including '@' in the local part, and check that 
other users of the 'email' format are not confused by that in some way.




After a bit of discussion, I decided to not send that follow-up, because 
'@' is technically only valid in quoted strings (which we didn't/don't 
support here) and AFAICT we used the same 'email' format from pve-common 
in some parts of PMG without noticeable complaints.



Other than that, i tested it and worked as advertised

Reviewed-By: Dominik Csapak 

On 2/15/21 13:24, Fabian Ebner wrote:
especially regarding the whitespace-agnostic behavior. And while 
we're at it,

also use the more complete email regex from pve-common.

Changes from v1:
 * re-use the email regex from pve-common
 * improve printing out mailto parameters to the cron file


common:

Fabian Ebner (2):
   sendmail: use more complete email regex and shellquote
   register email-or-username format

  src/PVE/JSONSchema.pm | 14 +-
  src/PVE/Tools.pm  | 17 -
  2 files changed, 25 insertions(+), 6 deletions(-)


guest-common:

Fabian Ebner (3):
   vzdump: command line: refactor handling prune-backups
   vzdump: command line: make sure mailto is comma-separated
   vzdump: mailto: use email-or-username-list format

  PVE/VZDump/Common.pm | 14 +-
  1 file changed, 5 insertions(+), 9 deletions(-)


manager:

Fabian Ebner (3):
   vzdump: refactor parsing mailto so it can be mocked
   test: vzdump: add tests for mailto
   test: vzdump: rename vzdump_new_retention_test.pl to
 vzdump_new_test.pl

  PVE/API2/VZDump.pm    |  11 +-
  PVE/VZDump.pm |  21 +++
  test/Makefile |   8 +-
  ...w_retention_test.pl => vzdump_new_test.pl} | 174 +-
  4 files changed, 198 insertions(+), 16 deletions(-)
  rename test/{vzdump_new_retention_test.pl => vzdump_new_test.pl} (74%)





___
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel





___
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel



___
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


[pve-devel] applied: [PATCH lxc-syscalld] update to tokio 1.0

2021-02-17 Thread Wolfgang Bumiller
applied

On Wed, Feb 17, 2021 at 11:39:38AM +0100, Fabian Grünbichler wrote:
> and switch from PollEvented to AsyncFd, dropping the direct mio
> dependency in turn.
> 
> Signed-off-by: Fabian Grünbichler 
> ---
>  Cargo.toml  |  3 +--
>  src/io/pipe.rs  |  9 +
>  src/io/polled_fd.rs | 45 +++--
>  src/main.rs |  2 +-
>  4 files changed, 14 insertions(+), 45 deletions(-)
> 
> diff --git a/Cargo.toml b/Cargo.toml
> index 1dced97..a337d44 100644
> --- a/Cargo.toml
> +++ b/Cargo.toml
> @@ -17,5 +17,4 @@ anyhow = "1.0"
>  lazy_static = "1.4"
>  libc = "0.2"
>  nix = "0.19"
> -mio = "0.6.21"
> -tokio = { version = "0.2.9", features = [ "rt-threaded", "io-driver", 
> "io-util" ] }
> +tokio = { version = "1.0", features = [ "rt-multi-thread", "io-util", "net" 
> ] }
> diff --git a/src/io/pipe.rs b/src/io/pipe.rs
> index 6b583fb..3b312a8 100644
> --- a/src/io/pipe.rs
> +++ b/src/io/pipe.rs
> @@ -5,7 +5,7 @@ use std::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd};
>  use std::pin::Pin;
>  use std::task::{Context, Poll};
>  
> -use tokio::io::{AsyncRead, AsyncWrite};
> +use tokio::io::{AsyncRead, AsyncWrite, ReadBuf};
>  
>  use crate::error::io_err_other;
>  use crate::io::polled_fd::PolledFd;
> @@ -86,13 +86,14 @@ impl AsyncRead for Pipe {
>  fn poll_read(
>  self: Pin<&mut Self>,
>  cx: &mut Context<'_>,
> -buf: &mut [u8],
> -) -> Poll> {
> +buf: &mut ReadBuf,
> +) -> Poll> {
>  self.fd.wrap_read(cx, || {
>  let fd = self.as_raw_fd();
> +let buf = buf.initialize_unfilled();
>  let size = 
> libc::size_t::try_from(buf.len()).map_err(io_err_other)?;
>  c_result!(unsafe { libc::read(fd, buf.as_mut_ptr() as *mut 
> libc::c_void, size) })
> -.map(|res| res as usize)
> +.map(|_| ())
>  })
>  }
>  }
> diff --git a/src/io/polled_fd.rs b/src/io/polled_fd.rs
> index 8a17d76..6ea1939 100644
> --- a/src/io/polled_fd.rs
> +++ b/src/io/polled_fd.rs
> @@ -2,11 +2,7 @@ use std::io;
>  use std::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd};
>  use std::task::{Context, Poll};
>  
> -use mio::event::Evented;
> -use mio::unix::EventedFd as MioEventedFd;
> -use mio::Poll as MioPoll;
> -use mio::{PollOpt, Ready, Token};
> -use tokio::io::PollEvented;
> +use tokio::io::unix::AsyncFd;
>  
>  use crate::tools::Fd;
>  
> @@ -43,41 +39,15 @@ impl IntoRawFd for EventedFd {
>  }
>  }
>  
> -impl Evented for EventedFd {
> -fn register(
> -&self,
> -poll: &MioPoll,
> -token: Token,
> -interest: Ready,
> -opts: PollOpt,
> -) -> io::Result<()> {
> -MioEventedFd(self.fd.as_ref()).register(poll, token, interest, opts)
> -}
> -
> -fn reregister(
> -&self,
> -poll: &MioPoll,
> -token: Token,
> -interest: Ready,
> -opts: PollOpt,
> -) -> io::Result<()> {
> -MioEventedFd(self.fd.as_ref()).reregister(poll, token, interest, 
> opts)
> -}
> -
> -fn deregister(&self, poll: &MioPoll) -> io::Result<()> {
> -MioEventedFd(self.fd.as_ref()).deregister(poll)
> -}
> -}
> -
>  #[repr(transparent)]
>  pub struct PolledFd {
> -fd: PollEvented,
> +fd: AsyncFd,
>  }
>  
>  impl PolledFd {
>  pub fn new(fd: Fd) -> tokio::io::Result {
>  Ok(Self {
> -fd: PollEvented::new(EventedFd::new(fd))?,
> +fd: AsyncFd::new(EventedFd::new(fd))?,
>  })
>  }
>  
> @@ -86,11 +56,11 @@ impl PolledFd {
>  cx: &mut Context,
>  func: impl FnOnce() -> io::Result,
>  ) -> Poll> {
> -ready!(self.fd.poll_read_ready(cx, mio::Ready::readable()))?;
> +let mut ready_guard = ready!(self.fd.poll_read_ready(cx))?;
>  match func() {
>  Ok(out) => Poll::Ready(Ok(out)),
>  Err(ref err) if err.kind() == io::ErrorKind::WouldBlock => {
> -self.fd.clear_read_ready(cx, mio::Ready::readable())?;
> +ready_guard.clear_ready();
>  Poll::Pending
>  }
>  Err(err) => Poll::Ready(Err(err)),
> @@ -102,11 +72,11 @@ impl PolledFd {
>  cx: &mut Context,
>  func: impl FnOnce() -> io::Result,
>  ) -> Poll> {
> -ready!(self.fd.poll_write_ready(cx))?;
> +let mut ready_guard = ready!(self.fd.poll_write_ready(cx))?;
>  match func() {
>  Ok(out) => Poll::Ready(Ok(out)),
>  Err(ref err) if err.kind() == io::ErrorKind::WouldBlock => {
> -self.fd.clear_write_ready(cx)?;
> +ready_guard.clear_ready();
>  Poll::Pending
>  }
>  Err(err) => Poll::Ready(Err(err)),
> @@ -128,7 +98,6 @@ impl IntoRawFd for PolledFd {
>  // its driver
>  self.fd
>  .into_inner()
> -.expect("failed to remove polled file descriptor

[pve-devel] [PATCH lxc-syscalld] update to tokio 1.0

2021-02-17 Thread Fabian Grünbichler
and switch from PollEvented to AsyncFd, dropping the direct mio
dependency in turn.

Signed-off-by: Fabian Grünbichler 
---
 Cargo.toml  |  3 +--
 src/io/pipe.rs  |  9 +
 src/io/polled_fd.rs | 45 +++--
 src/main.rs |  2 +-
 4 files changed, 14 insertions(+), 45 deletions(-)

diff --git a/Cargo.toml b/Cargo.toml
index 1dced97..a337d44 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -17,5 +17,4 @@ anyhow = "1.0"
 lazy_static = "1.4"
 libc = "0.2"
 nix = "0.19"
-mio = "0.6.21"
-tokio = { version = "0.2.9", features = [ "rt-threaded", "io-driver", 
"io-util" ] }
+tokio = { version = "1.0", features = [ "rt-multi-thread", "io-util", "net" ] }
diff --git a/src/io/pipe.rs b/src/io/pipe.rs
index 6b583fb..3b312a8 100644
--- a/src/io/pipe.rs
+++ b/src/io/pipe.rs
@@ -5,7 +5,7 @@ use std::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd};
 use std::pin::Pin;
 use std::task::{Context, Poll};
 
-use tokio::io::{AsyncRead, AsyncWrite};
+use tokio::io::{AsyncRead, AsyncWrite, ReadBuf};
 
 use crate::error::io_err_other;
 use crate::io::polled_fd::PolledFd;
@@ -86,13 +86,14 @@ impl AsyncRead for Pipe {
 fn poll_read(
 self: Pin<&mut Self>,
 cx: &mut Context<'_>,
-buf: &mut [u8],
-) -> Poll> {
+buf: &mut ReadBuf,
+) -> Poll> {
 self.fd.wrap_read(cx, || {
 let fd = self.as_raw_fd();
+let buf = buf.initialize_unfilled();
 let size = 
libc::size_t::try_from(buf.len()).map_err(io_err_other)?;
 c_result!(unsafe { libc::read(fd, buf.as_mut_ptr() as *mut 
libc::c_void, size) })
-.map(|res| res as usize)
+.map(|_| ())
 })
 }
 }
diff --git a/src/io/polled_fd.rs b/src/io/polled_fd.rs
index 8a17d76..6ea1939 100644
--- a/src/io/polled_fd.rs
+++ b/src/io/polled_fd.rs
@@ -2,11 +2,7 @@ use std::io;
 use std::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd};
 use std::task::{Context, Poll};
 
-use mio::event::Evented;
-use mio::unix::EventedFd as MioEventedFd;
-use mio::Poll as MioPoll;
-use mio::{PollOpt, Ready, Token};
-use tokio::io::PollEvented;
+use tokio::io::unix::AsyncFd;
 
 use crate::tools::Fd;
 
@@ -43,41 +39,15 @@ impl IntoRawFd for EventedFd {
 }
 }
 
-impl Evented for EventedFd {
-fn register(
-&self,
-poll: &MioPoll,
-token: Token,
-interest: Ready,
-opts: PollOpt,
-) -> io::Result<()> {
-MioEventedFd(self.fd.as_ref()).register(poll, token, interest, opts)
-}
-
-fn reregister(
-&self,
-poll: &MioPoll,
-token: Token,
-interest: Ready,
-opts: PollOpt,
-) -> io::Result<()> {
-MioEventedFd(self.fd.as_ref()).reregister(poll, token, interest, opts)
-}
-
-fn deregister(&self, poll: &MioPoll) -> io::Result<()> {
-MioEventedFd(self.fd.as_ref()).deregister(poll)
-}
-}
-
 #[repr(transparent)]
 pub struct PolledFd {
-fd: PollEvented,
+fd: AsyncFd,
 }
 
 impl PolledFd {
 pub fn new(fd: Fd) -> tokio::io::Result {
 Ok(Self {
-fd: PollEvented::new(EventedFd::new(fd))?,
+fd: AsyncFd::new(EventedFd::new(fd))?,
 })
 }
 
@@ -86,11 +56,11 @@ impl PolledFd {
 cx: &mut Context,
 func: impl FnOnce() -> io::Result,
 ) -> Poll> {
-ready!(self.fd.poll_read_ready(cx, mio::Ready::readable()))?;
+let mut ready_guard = ready!(self.fd.poll_read_ready(cx))?;
 match func() {
 Ok(out) => Poll::Ready(Ok(out)),
 Err(ref err) if err.kind() == io::ErrorKind::WouldBlock => {
-self.fd.clear_read_ready(cx, mio::Ready::readable())?;
+ready_guard.clear_ready();
 Poll::Pending
 }
 Err(err) => Poll::Ready(Err(err)),
@@ -102,11 +72,11 @@ impl PolledFd {
 cx: &mut Context,
 func: impl FnOnce() -> io::Result,
 ) -> Poll> {
-ready!(self.fd.poll_write_ready(cx))?;
+let mut ready_guard = ready!(self.fd.poll_write_ready(cx))?;
 match func() {
 Ok(out) => Poll::Ready(Ok(out)),
 Err(ref err) if err.kind() == io::ErrorKind::WouldBlock => {
-self.fd.clear_write_ready(cx)?;
+ready_guard.clear_ready();
 Poll::Pending
 }
 Err(err) => Poll::Ready(Err(err)),
@@ -128,7 +98,6 @@ impl IntoRawFd for PolledFd {
 // its driver
 self.fd
 .into_inner()
-.expect("failed to remove polled file descriptor from reactor")
 .into_raw_fd()
 }
 }
diff --git a/src/main.rs b/src/main.rs
index a0f34b7..ca4366d 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -100,7 +100,7 @@ fn main() {
 }
 };
 
-let mut rt = tokio::runtime::Runtime::new().expect("failed to spawn tokio 
runtime");
+let rt = tokio::runtime::Runtime::new().expect("failed to spawn tokio 
runt

Re: [pve-devel] [PATCH-SERIES v2] loosen up mailto regex for backwards compatibility

2021-02-17 Thread Fabian Ebner

On 17.02.21 10:52, Dominik Csapak wrote:

LGTM, nothing obvious that is wrong
one small thing though, after this patch i cannot
have an @ in the local part of an email anymore, though
i do not think that people actually use that?

e.g. foo@b...@example.com does not work anymore



Thanks for the review and for catching that! I'll send a follow-up (or 
does this warrant a v3?) including '@' in the local part, and check that 
other users of the 'email' format are not confused by that in some way.



Other than that, i tested it and worked as advertised

Reviewed-By: Dominik Csapak 

On 2/15/21 13:24, Fabian Ebner wrote:
especially regarding the whitespace-agnostic behavior. And while we're 
at it,

also use the more complete email regex from pve-common.

Changes from v1:
 * re-use the email regex from pve-common
 * improve printing out mailto parameters to the cron file


common:

Fabian Ebner (2):
   sendmail: use more complete email regex and shellquote
   register email-or-username format

  src/PVE/JSONSchema.pm | 14 +-
  src/PVE/Tools.pm  | 17 -
  2 files changed, 25 insertions(+), 6 deletions(-)


guest-common:

Fabian Ebner (3):
   vzdump: command line: refactor handling prune-backups
   vzdump: command line: make sure mailto is comma-separated
   vzdump: mailto: use email-or-username-list format

  PVE/VZDump/Common.pm | 14 +-
  1 file changed, 5 insertions(+), 9 deletions(-)


manager:

Fabian Ebner (3):
   vzdump: refactor parsing mailto so it can be mocked
   test: vzdump: add tests for mailto
   test: vzdump: rename vzdump_new_retention_test.pl to
 vzdump_new_test.pl

  PVE/API2/VZDump.pm    |  11 +-
  PVE/VZDump.pm |  21 +++
  test/Makefile |   8 +-
  ...w_retention_test.pl => vzdump_new_test.pl} | 174 +-
  4 files changed, 198 insertions(+), 16 deletions(-)
  rename test/{vzdump_new_retention_test.pl => vzdump_new_test.pl} (74%)





___
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel





___
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


Re: [pve-devel] [PATCH-SERIES v2] loosen up mailto regex for backwards compatibility

2021-02-17 Thread Dominik Csapak

LGTM, nothing obvious that is wrong
one small thing though, after this patch i cannot
have an @ in the local part of an email anymore, though
i do not think that people actually use that?

e.g. foo@b...@example.com does not work anymore

Other than that, i tested it and worked as advertised

Reviewed-By: Dominik Csapak 

On 2/15/21 13:24, Fabian Ebner wrote:

especially regarding the whitespace-agnostic behavior. And while we're at it,
also use the more complete email regex from pve-common.

Changes from v1:
 * re-use the email regex from pve-common
 * improve printing out mailto parameters to the cron file


common:

Fabian Ebner (2):
   sendmail: use more complete email regex and shellquote
   register email-or-username format

  src/PVE/JSONSchema.pm | 14 +-
  src/PVE/Tools.pm  | 17 -
  2 files changed, 25 insertions(+), 6 deletions(-)


guest-common:

Fabian Ebner (3):
   vzdump: command line: refactor handling prune-backups
   vzdump: command line: make sure mailto is comma-separated
   vzdump: mailto: use email-or-username-list format

  PVE/VZDump/Common.pm | 14 +-
  1 file changed, 5 insertions(+), 9 deletions(-)


manager:

Fabian Ebner (3):
   vzdump: refactor parsing mailto so it can be mocked
   test: vzdump: add tests for mailto
   test: vzdump: rename vzdump_new_retention_test.pl to
 vzdump_new_test.pl

  PVE/API2/VZDump.pm|  11 +-
  PVE/VZDump.pm |  21 +++
  test/Makefile |   8 +-
  ...w_retention_test.pl => vzdump_new_test.pl} | 174 +-
  4 files changed, 198 insertions(+), 16 deletions(-)
  rename test/{vzdump_new_retention_test.pl => vzdump_new_test.pl} (74%)





___
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel