crypto: Implement TLS Pre-Shared Keys (PSK).
PATCH v3 1/1 crypto: Implement TLS Pre-Shared Keys (PSK).
v2 was here:
https://lists.nongnu.org/archive/html/qemu-devel/2018-06/msg07404.html
v2 -> v3:
- Offer ECDHE-PSK key exchange algorithm too.
- Added a regression test to tests/test-crypto-tlssession.c
Rich.
PATCH v3 1/1 crypto: Implement TLS Pre-Shared Keys (PSK).
Pre-Shared Keys (PSK) is a simpler mechanism for enabling TLS connections than using certificates. It requires only a simple secret key:
$ mkdir -m 0700 /tmp/keys $ psktool -u rjones -p /tmp/keys/keys.psk $ cat /tmp/keys/keys.psk rjones:d543770c15ad93d76443fb56f501a31969235f47e999720ae8d2336f6a13fcbc
The key can be secretly shared between clients and servers. Clients must specify the directory containing the "keys.psk" file and a username (defaults to "qemu"). Servers must specify only the directory.
Example NBD client:
$ qemu-img info \
--object tls-creds-psk,id=tls0,dir=/tmp/keys,username=rjones,endpoint=client \
--image-opts \
file.driver=nbd,file.host=localhost,file.port=10809,file.tls-creds=tls0,file.export=/Example NBD server using qemu-nbd:
$ qemu-nbd -t -x / \
--object tls-creds-psk,id=tls0,endpoint=server,dir=/tmp/keys \
--tls-creds tls0 \
image.qcow2Example NBD server using nbdkit:
$ nbdkit -n -e / -fv \
--tls=on --tls-psk=/tmp/keys/keys.psk \
file file=disk.img--- crypto/Makefile.objs | 1 + crypto/tlscredspsk.c | 300 +++++++++++++++++++++++++++++++++ crypto/tlssession.c | 50 +++++- crypto/trace-events | 3 + include/crypto/tlscredspsk.h | 106 ++++++++++++ qemu-doc.texi | 37 ++++ qemu-options.hx | 24 +++ tests/Makefile.include | 4 +- tests/crypto-tls-psk-helpers.c | 50 ++++++ tests/crypto-tls-psk-helpers.h | 29 ++++ tests/test-crypto-tlssession.c | 185 +++++++++++++++++--- 11 files changed, 763 insertions(+), 26 deletions(-)
crypto/Makefile.objs +1 -0
@@ -15,6 +15,7 @@ crypto-obj-$(CONFIG_AF_ALG) += cipher-afalg.o crypto-obj-$(CONFIG_AF_ALG) += hash-afalg.o crypto-obj-y += tlscreds.o crypto-obj-y += tlscredsanon.o +crypto-obj-y += tlscredspsk.o crypto-obj-y += tlscredsx509.o crypto-obj-y += tlssession.o crypto-obj-y += secret.o
crypto/tlscredspsk.c new file +300 -0
300 lines not on this page · raw message
crypto/tlssession.c +48 -2
81 lines not on this page · raw message
crypto/trace-events +3 -0
@@ -7,6 +7,9 @@ qcrypto_tls_creds_get_path(void *creds, const char *filename, const char *path) # crypto/tlscredsanon.c qcrypto_tls_creds_anon_load(void *creds, const char *dir) "TLS creds anon load creds=%p dir=%s" +# crypto/tlscredspsk.c +qcrypto_tls_creds_psk_load(void *creds, const char *dir) "TLS creds psk load creds=%p dir=%s" + # crypto/tlscredsx509.c qcrypto_tls_creds_x509_load(void *creds, const char *dir) "TLS creds x509 load creds=%p dir=%s" qcrypto_tls_creds_x509_check_basic_constraints(void *creds, const char *file, int status) "TLS creds x509 check basic constraints creds=%p file=%s status=%d"
include/crypto/tlscredspsk.h new file +106 -0
106 lines not on this page · raw message
qemu-doc.texi +37 -0
@@ -1262,6 +1262,7 @@ The recommendation is for the server to keep its certificates in either * tls_generate_server:: * tls_generate_client:: * tls_creds_setup:: +* tls_psk:: @end menu @node tls_generate_ca @subsection Setup the Certificate Authority
@@ -1510,6 +1511,42 @@ example with VNC: $QEMU -vnc 0.0.0.0:0,tls-creds=tls0 @end example +@node tls_psk +@subsection TLS Pre-Shared Keys (PSK) + +Instead of using certificates, you may also use TLS Pre-Shared Keys +(TLS-PSK). This can be simpler to set up than certificates but is +less scalable. + +Use the GnuTLS @code{psktool} program to generate a @code{keys.psk} +file containing one or more usernames and random keys: + +@example +mkdir -m 0700 /tmp/keys +psktool -u rich -p /tmp/keys/keys.psk +@end example + +TLS-enabled servers such as qemu-nbd can use this directory like so: + +@example +qemu-nbd \ + -t -x / \ + --object tls-creds-psk,id=tls0,endpoint=server,dir=/tmp/keys \ + --tls-creds tls0 \ + image.qcow2 +@end example + +When connecting from a qemu-based client you must specify the +directory containing @code{keys.psk} and an optional @var{username} +(defaults to ``qemu''): + +@example +qemu-img info \ + --object tls-creds-psk,id=tls0,dir=/tmp/keys,username=rich,endpoint=client \ + --image-opts \ + file.driver=nbd,file.host=localhost,file.port=10809,file.tls-creds=tls0,file.export=/ +@end example + @node gdb_usage @section GDB usage
qemu-options.hx +24 -0
@@ -4099,6 +4099,30 @@ expensive operation that consumes random pool entropy, so it is recommended that a persistent set of parameters be generated upfront and saved. +@item -object tls-creds-psk,id=@var{id},endpoint=@var{endpoint},dir=@var{/path/to/keys/dir}[,username=@var{username}] + +Creates a TLS Pre-Shared Keys (PSK) credentials object, which can be used to provide +TLS support on network backends. The @option{id} parameter is a unique +ID which network backends will use to access the credentials. The +@option{endpoint} is either @option{server} or @option{client} depending +on whether the QEMU network backend that uses the credentials will be +acting as a client or as a server. For clients only, @option{username} +is the username which will be sent to the server. If omitted +it defaults to ``qemu''. + +The @var{dir} parameter tells QEMU where to find the keys file. +It is called ``@var{dir}/keys.psk'' and contains ``username:key'' +pairs. This file can most easily be created using the GnuTLS +@code{psktool} program. + +For server endpoints, @var{dir} may also contain a file +@var{dh-params.pem} providing diffie-hellman parameters to use +for the TLS server. If the file is missing, QEMU will generate +a set of DH parameters at startup. This is a computationally +expensive operation that consumes random pool entropy, so it is +recommended that a persistent set of parameters be generated +upfront and saved. + @item -object tls-creds-x509,id=@var{id},endpoint=@var{endpoint},dir=@var{/path/to/cred/dir},priority=@var{priority},verify-peer=@var{on|off},passwordid=@var{id} Creates a TLS anonymous credentials object, which can be used to provide
tests/Makefile.include +3 -1
@@ -723,7 +723,9 @@ tests/test-crypto-tlscredsx509$(EXESUF): tests/test-crypto-tlscredsx509.o \ tests/test-crypto-tlssession.o-cflags := $(TASN1_CFLAGS) tests/test-crypto-tlssession$(EXESUF): tests/test-crypto-tlssession.o \ - tests/crypto-tls-x509-helpers.o tests/pkix_asn1_tab.o $(test-crypto-obj-y) + tests/crypto-tls-x509-helpers.o tests/pkix_asn1_tab.o \ + tests/crypto-tls-psk-helpers.o \ + $(test-crypto-obj-y) tests/test-util-sockets$(EXESUF): tests/test-util-sockets.o \ tests/socket-helpers.o $(test-util-obj-y) tests/test-io-task$(EXESUF): tests/test-io-task.o $(test-io-obj-y)
tests/crypto-tls-psk-helpers.c new file +50 -0
50 lines not on this page · raw message
tests/crypto-tls-psk-helpers.h new file +29 -0
@@ -0,0 +1,29 @@ +/* +* Copyright (C) 2015-2018 Red Hat, Inc. +* +* 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 +* <http://www.gnu.org/licenses/>. +* +* Author: Richard W.M. Jones <[email protected]> +*/ + +#include <gnutls/gnutls.h> + +#ifdef QCRYPTO_HAVE_TLS_TEST_SUPPORT +# include "qemu-common.h" + +void test_tls_psk_init (const char *keyfile); +void test_tls_psk_cleanup (const char *keyfile); + +#endif /* QCRYPTO_HAVE_TLS_TEST_SUPPORT */
tests/test-crypto-tlssession.c +162 -23
248 lines not on this page · raw message
Signature · 1 line
2.17.1
On 06/28/2018 08:22 AM, Richard W.M. Jones wrote:
In the subject line: most commit summaries don't have a trailing '.'.
Quoted 14 lines
Pre-Shared Keys (PSK) is a simpler mechanism for enabling TLS connections than using certificates. It requires only a simple secret key:
$ mkdir -m 0700 /tmp/keys $ psktool -u rjones -p /tmp/keys/keys.psk $ cat /tmp/keys/keys.psk rjones:d543770c15ad93d76443fb56f501a31969235f47e999720ae8d2336f6a13fcbcThe key can be secretly shared between clients and servers. Clients must specify the directory containing the "keys.psk" file and a username (defaults to "qemu"). Servers must specify only the directory.
Quoted 6 lines
Example NBD client:
$ qemu-img info \ --object tls-creds-psk,id=tls0,dir=/tmp/keys,username=rjones,endpoint=client \ --image-opts \ file.driver=nbd,file.host=localhost,file.port=10809,file.tls-creds=tls0,file.export=/
Not your problem, but it would be nice if someday our --object command line arguments also had QMP counterparts to better document what key/value pairs each particular object type permits/requires (yeah, you can do it via QMP now, but object-add is an untyped command that just passes a raw dict through rather than benefitting from type-safe parsing).
Quoted 15 lines
Signed-off-by Richard W.M. Jones <[email protected]>--- crypto/Makefile.objs | 1 + crypto/tlscredspsk.c | 300 +++++++++++++++++++++++++++++++++ crypto/tlssession.c | 50 +++++- crypto/trace-events | 3 + include/crypto/tlscredspsk.h | 106 ++++++++++++ qemu-doc.texi | 37 ++++ qemu-options.hx | 24 +++ tests/Makefile.include | 4 +- tests/crypto-tls-psk-helpers.c | 50 ++++++ tests/crypto-tls-psk-helpers.h | 29 ++++ tests/test-crypto-tlssession.c | 185 +++++++++++++++++--- 11 files changed, 763 insertions(+), 26 deletions(-)
crypto/tlscredspsk.c line 36
Quoted 6 lines
crypto/tlscredspsk.c new file +6
-0+static int +lookup_key (const char *pskfile,const char *username,gnutls_datum_t *key, +Error **errp) +{ +FILE *fp; +char line[1024 ];/* Maximum key length in psktool is 512 bytes. */
That's true for a valid file produced by psktool, but...
crypto/tlscredspsk.c line 40
Quoted 4 lines
crypto/tlscredspsk.c new file +4
-0+size_t ulen =strlen (username); +size_t len; + + fp =fopen (pskfile,"r" );
Do we want to consider the use of qemu_open() to allow qemu to read from a pre-opened fd, rather than requiring the ability to open() from the file system? (May matter if we want to combine crypto usage with a locked-down qemu that has seccomp or selinux preventing bare open). But that gets tricky since there may be more than one file within the directory to open, and the existing x509 certificate handling is also impacted by such a design decision, so that's more a question for Dan and not necessarily a problem in this patch.
crypto/tlscredspsk.c line 46
Quoted 6 lines
crypto/tlscredspsk.c new file +6
-0+if (fp ==NULL ) { +error_setg_errno (errp, errno,"Cannot open PSK file %s" , pskfile); +return -1 ; + } +while (fgets (line,sizeof line, fp) !=NULL ) { +if (strncmp (line, username, ulen) ==0 && line[ulen] ==':' ) {
...can't this misbehave if the user accidentally points to some other file (rather than one produced by psktool)? I'm wondering if a getline() loop would be smarter than trying to use a fixed-length buffer.
Quoted 17 lines
crypto/tlscredspsk.c new file +17
-0+ len =strlen (line); +if (len >0 && line[len -1 ] =='\n' ) { + len--; + line[len] ='\0' ; + } + key->data = (unsigned char *)g_strdup (&line[ulen +1 ]); + key->size = len - ulen -1 ; +fclose (fp); +return 0 ; + } + } +fclose (fp); +error_setg (errp,"Username %s not found in PSK file %s" , + username, pskfile); +return -1 ; +} +
...
crypto/tlscredspsk.c line 248
Quoted 9 lines
crypto/tlscredspsk.c new file +9
-0+ +static void +qcrypto_tls_creds_psk_prop_set_username (Object *obj, +const char *value, + Error **errp G_GNUC_UNUSED) +{ +QCryptoTLSCredsPSK *creds =QCRYPTO_TLS_CREDS_PSK (obj); + + creds->username =g_strdup (value);
Does it make sense to forbid this operation on servers (since it only makes sense for clients)?
Quoted 30 lines
+/**
+ * QCryptoTLSCredsPSK:
+ *
+ * The QCryptoTLSCredsPSK object provides a representation
+ * of the Pre-Shared Key credential used to perform a TLS handshake.
+ *
+ * This is a user creatable object, which can be instantiated
+ * viaobject_new_propv():
+ *
+ * <example>+ * <title>Creating TLS-PSK credential objects in code</title> + * <programlisting> + * Object *obj; + * Error *err = NULL; + * obj = object_new_propv(TYPE_QCRYPTO_TLS_CREDS_PSK, + * "tlscreds0", + * &err, + * "dir", "/path/to/dir", + * "endpoint", "client", + * NULL);+ * </programlisting>
+ * </example>
+ *
+ * Or via QMP:
+ *
+ * <example>
+ * <title>Creating TLS-PSK credential objects via QMP</title>
+ * <programlisting>
+ * {
+ * "execute": "object-add", "arguments": {
Quoted 6 lines
+ * "id": "tlscreds0", + * "qom-type": "tls-creds-psk", + * "props": {+ * "dir": "/path/to/dir",
+ * "endpoint": "client",
+ * }
No trailing comma after "client"
Quoted 11 lines
+ * }
+ * }
+ * </programlisting>
+ * </example>
+ *
+ * Or via the CLI:
+ *
+ * <example>
+ * <title>Creating TLS-PSK credential objects via CLI</title>
+ * <programlisting>
+ * qemu-system-x86_64 -object tls-creds-psk,id=tlscreds0,\
I'd use '--object' here, since only that form will also apply to qemu-nbd.
Quoted 10 lines
+ * endpoint=client,dir=/path/to/dir[,username=qemu]
+ * </programlisting>
+ * </example>
+ *
+ * The PSK file can be created and managed using psktool.
+ */qemu-options.hx +2
-0+ +++ b/qemu-options.hx
qemu-options.hx expensive operation that consumes random pool entropy, so it is · line 4102
Quoted 4 lines
qemu-options.hx +1
-0@@ -4099,6 +4099,30 @@ expensive operation that consumes random pool entropy, so it is recommended that a persistent set of parameters be generated upfront and saved. +@item -object tls-creds-psk,id=@var{id},endpoint=@var{endpoint},dir=@var{/path/to/keys/dir}[,username=@var{username}]
Another candidate for spelling as --object. (Yeah, I know, this file has a lot of pre-existing examples that should also be fixed)
Quoted 12 lines
qemu-options.hx +12
-0+ +Creates a TLS Pre-Shared Keys (PSK) credentials object, which can be used to provide +TLS support on network backends. The @option{id} parameter is a unique +ID which network backends will use to access the credentials. The +@option{endpoint} is either @option{server} or @option{client} depending +on whether the QEMU network backend that uses the credentials will be +acting as a client or as a server. For clients only, @option{username} +is the username which will be sent to the server. If omitted +it defaults to ``qemu''. + +The @var{dir} parameter tells QEMU where to find the keys file. +It is called ``@var{dir}/keys.psk'' and contains ``username:key''
qemu-options.hx expensive operation that consumes random pool entropy, so it is · line 4124
Quoted 10 lines
qemu-options.hx +10
-0+pairs. This file can most easily be created using the GnuTLS +@code{psktool} program. + +For server endpoints, @var{dir} may also contain a file +@var{dh-params.pem} providing diffie-hellman parameters to use +for the TLS server. If the file is missing, QEMU will generate +a set of DH parameters at startup. This is a computationally +expensive operation that consumes random pool entropy, so it is +recommended that a persistent set of parameters be generated +upfront and saved.
s/upfront/up front/
Review expensive operation that consumes random pool entropy, so it is · line 4125
Quoted 1 line
(quoted diff) +1
-0+++ b/tests/crypto-tls-psk-helpers.c
Otherwise, I'm not spotting problems, but as it touches crypto, I'd also get Dan's review.
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
Eric Blake
Acked-byQuoted 25 lines · Eric Blake
On 06/28/2018 08:22 AM, Richard W.M. Jones wrote:
In the subject line: most commit summaries don't have a trailing '.'.
Quoted 21 lines
Pre-Shared Keys (PSK) is a simpler mechanism for enabling TLS connections than using certificates. It requires only a simple secret key:
$ mkdir -m 0700 /tmp/keys $ psktool -u rjones -p /tmp/keys/keys.psk $ cat /tmp/keys/keys.pskrjones:d543770c15ad93d76443fb56f501a31969235f47e999720ae8d2336f6a13fcbc
The key can be secretly shared between clients and servers. Clients must specify the directory containing the "keys.psk" file and a username (defaults to "qemu"). Servers must specify only the directory.
Example NBD client:
$ qemu-img info \ --object tls-creds-psk,id=tls0,dir=/tmp/keys,username=rjones,endpoint=client \ --image-opts \
Quoted 6 lines
Quoted 1 line
file.driver=nbd,file.host=localhost,file.port=10809,file.tls-creds=tls0,file.export=/
Otherwise, I'm not spotting problems, but as it touches crypto, I'd also get Dan's review.
Because of the immediate use for NBD, I'm willing to take this through the NBD tree if Dan gives a review or ack. Or, if Dan wants it through the crypto tree (and my minor nits are addressed),
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
Quoted 8 lines · Eric Blake
crypto/tlscredspsk.c line 46
Quoted 2 lines · Richard W.M. Jones
crypto/tlscredspsk.c new file +2
-0+while (fgets (line,sizeof line, fp) !=NULL ) { +if (strncmp (line, username, ulen) ==0 && line[ulen] ==':' ) {...can't this misbehave if the user accidentally points to some other file (rather than one produced by psktool)? I'm wondering if a
getline()loop would be smarter than trying to use a fixed-length buffer.
I would definitely have used getline, but after examining the qemu source I wasn't sure if it was permitted. It's only used in qga now. Is it available on Win32 for example?
Thanks for the rest of the comments. I'll modify those where required in the next version.
Rich.
Signature · 4 lines
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-builder quickly builds VMs from scratch http://libguestfs.org/virt-builder.1.html
Quoted 10 lines · Richard W.M. Jones
Quoted 8 lines · Eric Blake
crypto/tlscredspsk.c line 46
Quoted 2 lines · Richard W.M. Jones
crypto/tlscredspsk.c new file +2
-0+while (fgets (line,sizeof line, fp) !=NULL ) { +if (strncmp (line, username, ulen) ==0 && line[ulen] ==':' ) {...can't this misbehave if the user accidentally points to some other file (rather than one produced by psktool)? I'm wondering if a
getline()loop would be smarter than trying to use a fixed-length buffer.
Quoted 6 lines
I would definitely have used getline, but after examining the qemu source I wasn't sure if it was permitted. It's only used in qga now. Is it available on Win32 for example?
Thanks for the rest of the comments. I'll modify those where required in the next version.
These key files are fairly small so IMHO it would be acceptable to just read the entire file into memory in one go using g_file_get_contents(), and then g_str_split() on "\n"
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Quoted 60 lines · Eric Blake
On 06/28/2018 08:22 AM, Richard W.M. Jones wrote:
In the subject line: most commit summaries don't have a trailing '.'.
Quoted 14 lines
Pre-Shared Keys (PSK) is a simpler mechanism for enabling TLS connections than using certificates. It requires only a simple secret key:
$ mkdir -m 0700 /tmp/keys $ psktool -u rjones -p /tmp/keys/keys.psk $ cat /tmp/keys/keys.psk rjones:d543770c15ad93d76443fb56f501a31969235f47e999720ae8d2336f6a13fcbcThe key can be secretly shared between clients and servers. Clients must specify the directory containing the "keys.psk" file and a username (defaults to "qemu"). Servers must specify only the directory.
Quoted 6 lines
Example NBD client:
$ qemu-img info \ --object tls-creds-psk,id=tls0,dir=/tmp/keys,username=rjones,endpoint=client \ --image-opts \ file.driver=nbd,file.host=localhost,file.port=10809,file.tls-creds=tls0,file.export=/Not your problem, but it would be nice if someday our --object command line arguments also had QMP counterparts to better document what key/value pairs each particular object type permits/requires (yeah, you can do it via QMP now, but object-add is an untyped command that just passes a raw dict through rather than benefitting from type-safe parsing).
Quoted 15 lines
Signed-off-by Richard W.M. Jones <[email protected]>--- crypto/Makefile.objs | 1 + crypto/tlscredspsk.c | 300 +++++++++++++++++++++++++++++++++ crypto/tlssession.c | 50 +++++- crypto/trace-events | 3 + include/crypto/tlscredspsk.h | 106 ++++++++++++ qemu-doc.texi | 37 ++++ qemu-options.hx | 24 +++ tests/Makefile.include | 4 +- tests/crypto-tls-psk-helpers.c | 50 ++++++ tests/crypto-tls-psk-helpers.h | 29 ++++ tests/test-crypto-tlssession.c | 185 +++++++++++++++++--- 11 files changed, 763 insertions(+), 26 deletions(-)crypto/tlscredspsk.c line 36
Quoted 6 lines
crypto/tlscredspsk.c new file +6
-0+static int +lookup_key (const char *pskfile,const char *username,gnutls_datum_t *key, +Error **errp) +{ +FILE *fp; +char line[1024 ];/* Maximum key length in psktool is 512 bytes. */ That's true for a valid file produced by psktool, but...
crypto/tlscredspsk.c line 40
Quoted 4 lines
crypto/tlscredspsk.c new file +4
-0+size_t ulen =strlen (username); +size_t len; + + fp =fopen (pskfile,"r" );
Quoted 8 lines
Do we want to consider the use of
qemu_open()to allow qemu to read from a pre-opened fd, rather than requiring the ability toopen()from the file system? (May matter if we want to combine crypto usage with a locked-down qemu that has seccomp or selinux preventing bare open). But that gets tricky since there may be more than one file within the directory to open, and the existing x509 certificate handling is also impacted by such a design decision, so that's more a question for Dan and not necessarily a problem in this patch.
Yeah, given our approach of passing in a dir, not a file, I don't think it is viable to expect to use qemu_open() and FD passing.
Quoted 11 lines
crypto/tlscredspsk.c line 248
Quoted 8 lines
crypto/tlscredspsk.c new file +8
-0+static void +qcrypto_tls_creds_psk_prop_set_username (Object *obj, +const char *value, + Error **errp G_GNUC_UNUSED) +{ +QCryptoTLSCredsPSK *creds =QCRYPTO_TLS_CREDS_PSK (obj); + + creds->username =g_strdup (value);Does it make sense to forbid this operation on servers (since it only makes sense for clients)?
We can't validate that here, because we can't guarantee that 'endpoint' is set before 'username' is set.
We could enforce it in the setter for the "loaded" property as that is set only after every other property is set.
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Quoted 10 lines · Daniel P. Berrangé
Quoted 2 lines · Eric Blake
Does it make sense to forbid this operation on servers (since it only makes sense for clients)?
We can't validate that here, because we can't guarantee that 'endpoint' is set before 'username' is set.
We could enforce it in the setter for the "loaded" property as that is set only after every other property is set.
As far as I can see we could only warn here, since the set_loaded function returns void.
Rich.
Signature · 5 lines
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://people.redhat.com/~rjones/virt-top
Quoted 9 lines · Richard W.M. Jones
Quoted 8 lines · Daniel P. Berrangé
Quoted 2 lines · Eric Blake
Does it make sense to forbid this operation on servers (since it only makes sense for clients)?
We can't validate that here, because we can't guarantee that 'endpoint' is set before 'username' is set.
Quoted 5 lines
Quoted 2 lines
We could enforce it in the setter for the "loaded" property as that is set only after every other property is set.
As far as I can see we could only warn here, since the
set_loadedfunction returns void.
Welcome to qemu's unusual error reporting style. You just call error_setg(errp, ...) to report an error - return value is not relevant - the caller simply examines whether 'Error *' is set after the call finishes.
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|