Skip to content
  • Markus Armbruster's avatar
    635db18f
    qmp: Clean up how we enforce capability negotiation · 635db18f
    Markus Armbruster authored
    
    
    To enforce capability negotiation before normal operation,
    handle_qmp_command() inspects every command before it's handed off to
    qmp_dispatch().  This is a bit of a layering violation, and results in
    duplicated code.
    
    Before capability negotiation (!cur_mon->in_command_mode), we fail
    commands other than "qmp_capabilities".  This is what enforces
    capability negotiation.
    
    Afterwards, we fail command "qmp_capabilities".
    
    Clean this up as follows.
    
    The obvious place to fail a command is the command itself, so move the
    "afterwards" check to qmp_qmp_capabilities().
    
    We do the "before" check in every other command, but that would be
    bothersome.  Instead, start with an alternate list of commands that
    contains only "qmp_capabilities".  Switch to the full list in
    qmp_qmp_capabilities().
    
    Additionally, replace the generic human-readable error message for
    CommandNotFound by one that reminds the user to run qmp_capabilities.
    Without that, we'd regress commit 2d5a8346.
    
    Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
    Message-Id: <1488544368-30622-8-git-send-email-armbru@redhat.com>
    [Mirco-optimization squashed in, commit message typo fixed]
    Reviewed-by: default avatarEric Blake <eblake@redhat.com>
    635db18f
    qmp: Clean up how we enforce capability negotiation
    Markus Armbruster authored
    
    
    To enforce capability negotiation before normal operation,
    handle_qmp_command() inspects every command before it's handed off to
    qmp_dispatch().  This is a bit of a layering violation, and results in
    duplicated code.
    
    Before capability negotiation (!cur_mon->in_command_mode), we fail
    commands other than "qmp_capabilities".  This is what enforces
    capability negotiation.
    
    Afterwards, we fail command "qmp_capabilities".
    
    Clean this up as follows.
    
    The obvious place to fail a command is the command itself, so move the
    "afterwards" check to qmp_qmp_capabilities().
    
    We do the "before" check in every other command, but that would be
    bothersome.  Instead, start with an alternate list of commands that
    contains only "qmp_capabilities".  Switch to the full list in
    qmp_qmp_capabilities().
    
    Additionally, replace the generic human-readable error message for
    CommandNotFound by one that reminds the user to run qmp_capabilities.
    Without that, we'd regress commit 2d5a8346.
    
    Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
    Message-Id: <1488544368-30622-8-git-send-email-armbru@redhat.com>
    [Mirco-optimization squashed in, commit message typo fixed]
    Reviewed-by: default avatarEric Blake <eblake@redhat.com>
Loading